History

update

bellard committed 25 years ago

Commit 34a14a01 parent b9455a73 files · +69 −43Browse files

Unified · Split

3 files
  1. Makefile +11 −10
  2. README +50 −29
  3. TODO +8 −4
Makefile+11−10
@@ -3,7 +3,7 @@ · 2 unmodified lines
3#3#
4prefix=/usr/local4prefix=/usr/local
5 5
6CFLAGS=-O2 -g -Wall -Wno-parentheses -I.6CFLAGS=-O2 -g -Wall -Wno-parentheses -Wno-missing-braces -I.
7LIBS=-ldl7LIBS=-ldl
8#CFLAGS=-O2 -g -Wall -Wno-parentheses -I. -pg -static -DPROFILE8#CFLAGS=-O2 -g -Wall -Wno-parentheses -I. -pg -static -DPROFILE
9#LIBS=9#LIBS=
@@ -32,11 +32,15 @@ test.out: tcc prog.c · 22 unmodified lines
32run: tcc prog.c32run: tcc prog.c
33 ./tcc -I. prog.c33 ./tcc -I. prog.c
34 34
35run2: tcc tcc.c prog.c35# iterated test2 (compile tcc then compile prog.c !)
36 ./tcc -I. tcc.c -I. prog.c36test2: tcc tcc.c prog.c
37 ./tcc -I. tcc.c -I. prog.c > test.out2
38 @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
37 39
38run3: tcc tcc.c prog.c40# iterated test3 (compile tcc then compile tcc then compile prog.c !)
39 ./tcc -I. tcc.c -I. tcc.c -I. prog.c41test3: tcc tcc.c prog.c
42 ./tcc -I. tcc.c -I. tcc.c -I. prog.c > test.out3
43 @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
40 44
41# speed test45# speed test
42speed: tcc ex2 ex346speed: tcc ex2 ex3
@@ -70,13 +74,10 @@ clean: · 27 unmodified lines
70 74
71# target for development75# target for development
72 76
73%.bin: %.c tcct77%.bin: %.c tcc
74 ./tcct -I. $< $@78 ./tcc -o $@ -I. $<
75 $(DISAS) $@79 $(DISAS) $@
76 80
77tcct: tcc.c
78 gcc -DTEST $(CFLAGS) -o $@ $< -ldl
79
80instr.o: instr.S81instr.o: instr.S
81 gcc -O2 -Wall -g -c -o $@ $<82 gcc -O2 -Wall -g -c -o $@ $<
82 83
README+50−29
@@ -5,16 +5,18 @@ Features: · 4 unmodified lines
5--------5--------
6 6
7- SMALL! You can compile and execute C code everywhere, for example on7- SMALL! You can compile and execute C code everywhere, for example on
8 rescue disks (25KB for x86 executable).8 rescue disks (27KB for x86 TCC executable).
9 9
10- FAST! tcc generates optimized x86 code. No byte code overhead.10- FAST! tcc generates optimized x86 code. No byte code
11 overhead. Compiles, assemble and link about 7 times faster than 'gcc
12 -O0'.
11 13
12- UNLIMITED! Any C dynamic library can be used directly. TCC is14- UNLIMITED! Any C dynamic library can be used directly. TCC is
13 heading torward full ANSI C compliance. TCC can of course compile15 heading torward full ISOC99 compliance. TCC can of course compile
14 itself.16 itself.
15 17
16- Compile and execute C source directly. No linking or assembly18- Compile and execute C source directly. No linking or assembly
17 necessary. Full C preprocessor included.19 necessary. Full C preprocessor included.
18 20
19- C script supported : just add '#!/usr/local/bin/tcc' at the first21- C script supported : just add '#!/usr/local/bin/tcc' at the first
20 line of your C source, and execute it directly from the command22 line of your C source, and execute it directly from the command
@@ -27,7 +29,7 @@ Documentation: · 6 unmodified lines
27 29
28***TCC currently only work on Linux x86***.30***TCC currently only work on Linux x86***.
29 31
30Type 'make install' to compile and install tcc in /usr/local and32Type 'make install' to compile and install tcc in /usr/local/bin and
31/usr/local/lib/tcc.33/usr/local/lib/tcc.
32 34
332) Introduction352) Introduction
@@ -64,7 +66,7 @@ files, add one which includes all your sources. · 30 unmodified lines
644) Examples664) Examples
65 67
66ex1.c: simplest example (hello world). Can also be launched directly68ex1.c: simplest example (hello world). Can also be launched directly
67as a script: ./ex2.c.69as a script: './ex1.c'.
68 70
69ex2.c: more complicated example: find a number with the four71ex2.c: more complicated example: find a number with the four
70operations given a list of numbers (benchmark).72operations given a list of numbers (benchmark).
@@ -72,12 +74,12 @@ operations given a list of numbers (benchmark). · 1 unmodified line
72ex3.c: compute fibonacci numbers (benchmark).74ex3.c: compute fibonacci numbers (benchmark).
73 75
74ex4.c: more complicated: X11 program. Very complicated test in fact76ex4.c: more complicated: X11 program. Very complicated test in fact
75because standard headers are being used ! Currently slow because77because standard headers are being used !
76parsing does not use hash tables.
77 78
78ex5.c: 'hello world' with standard glibc headers.79ex5.c: 'hello world' with standard glibc headers.
79 80
80tcc.c: TCC can compile itself. Used to check the code generator.81tcc.c: TCC can of course compile itself. Used to check the code
82generator.
81 83
82prog.c: auto test for TCC which tests many subtle possible bugs. Used84prog.c: auto test for TCC which tests many subtle possible bugs. Used
83when doing 'make test'.85when doing 'make test'.
@@ -91,38 +93,57 @@ Exact differences with ANSI C: · 7 unmodified lines
91 rare cases, preprocessed numbers are not handled exactly as in ANSI93 rare cases, preprocessed numbers are not handled exactly as in ANSI
92 C. This approach has the advantage of being simpler and FAST!94 C. This approach has the advantage of being simpler and FAST!
93 95
94 - __LINE__, __FILE__, __DATE__, __TIME__ are currently not handled.
95
96 - #line not handled
97
982) C language962) C language
99 97
100- Parsing: variables cannot be initialized ('int a = 1' or 'int tab[2] =
101 {1, 2}' not supported).
102
103- Cannot pass struct/union as value. Cannot assign struct/union (use98- Cannot pass struct/union as value. Cannot assign struct/union (use
104 memcpy instead).99 memcpy instead).
105 100
106- Types: floating point numbers are not supported.101- Types: floating point numbers are not supported yet.
107 102
108- (BUG) 'char' and 'short' casts do not truncate correctly.103- (BUG) 'char' and 'short' casts do not truncate correctly.
109 104
110- 'sizeof' may not work if too complex expression is given.105- 'sizeof' may not work if too complex expression is given.
111 106
112Supported C extensions:107- bit fields are not supported.
113----------------------108
109- L'c' or L"string" for wide chars are parsed but not handled as wchar_t.
110
111- Cannot initialize auto (=local) arrays with implicit size
112 (workaround: specificy exact size in array declaration). Cannot
113 initialize auto arrays with strings.
114
1153) Linking
116
117- extern variables must appear in a referenced dll and cannot appear
118 in current source.
119
120Supported ANSI C extensions:
121---------------------------
122
123- 'inline' keyword is ignored (ISOC99).
124
125- 'restrict' keyword is ignored (ISOC99).
126
127- '__func__' is a string variable containing the current function name (ISOC99).
128
129- variadic macros: __VA_ARGS__ can be used for function-like macros (ISOC99):
130 #define dprintf(level, __VA_ARGS__) printf(__VA_ARGS__).
131
132- declarations can appear anywhere in a block (ISOC99).
114 133
115- 'inline' keyword is ignored.134- array and struct/union elements can be initialized in any order by
135 using designators (.e. { [0].x = 1 }) (ISOC99).
116 136
137- binary digits can be entered ('0b101' instead of '5').
117 138
118Technical Description:139Technical Description:
119---------------------140---------------------
120 141
121This is not my first C compiler (see my 'fbcc' compiler) but it142This is not my first C compiler (see my 'fbcc' compiler) but it
122contains the first C preprocessor I wrote. The project started as a143contains the first C preprocessor I wrote. The project started as a
123joke to make the smallest C compiler. Then I expanded it torward ANSI144joke to make the smallest C compiler. Then I expanded it torward
124compliance. This C compiler is particular because each feature was145ISOC99 compliance. This C compiler is particular because each feature
125added while trying to be as simple and compact as possible. For146was added while trying to be as simple and compact as possible. For
126example, no intermediate structure is used to store code or147example, no intermediate structure is used to store code or
127expressions.148expressions.
128 149
@@ -137,10 +158,10 @@ registers are used. When more registers are needed, one register is · 8 unmodified lines
137flushed in a new local variable.158flushed in a new local variable.
138 159
139Constant propagation is done for all operations. Multiplications and160Constant propagation is done for all operations. Multiplications and
140divisions are optimized to shifts when appropriate. Logical operators161divisions are optimized to shifts when appropriate. Comparison
141are optimized by maintaining a special cache for the processor162operators are optimized by maintaining a special cache for the
142flags. &&, || and ! are optimized by maintaining a special 'jmp163processor flags. &&, || and ! are optimized by maintaining a special
143target' value. No other jmp optimization is currently performed164'jmp target' value. No other jmp optimization is currently performed
144because it would require to store the code in a more abstract fashion.165because it would require to store the code in a more abstract fashion.
145 166
146The types and values descriptions are stored in a single 'int'167The types and values descriptions are stored in a single 'int'
@@ -151,10 +172,10 @@ solution. · 4 unmodified lines
151License:172License:
152-------173-------
153 174
154TCC is distributed under the GNU Generic Public License (see COPYING175TCC is distributed under the GNU General Public License (see COPYING
155file). 176file).
156 177
157I accept only patches where you give your copyright explictely to me178I accept only patches where you give your copyright explictely to me
158to simplify licensing issues.179to simplify licensing issues.
159 180
160Fabrice Bellard - Nov 11, 2001.181Fabrice Bellard - Nov 17, 2001.
TODO+8−4
@@ -2,10 +2,12 @@ TODO list: · 1 unmodified line
2 2
3Critical:3Critical:
4 4
5- initializers5- add structure assign.
6- add hash tables for symbols (useful for long programs)6- fix 'char' and 'short' casts.
7- 0 is pointer - fix type compare7- 0 is pointer - fix type compare
8- fix L'' and L"" wide chars
8- add message if external function or variable not found.9- add message if external function or variable not found.
10- function pointers to forward reference (patch code generator).
9- add float/double support (should be as small as possible while being11- add float/double support (should be as small as possible while being
10 usable for RISC code generator too).12 usable for RISC code generator too).
11 13
@@ -13,6 +15,8 @@ Not critical: · 1 unmodified line
13 15
14- fix preprocessor symbol redefinition 16- fix preprocessor symbol redefinition
15- better constant opt (&&, ||, ?:)17- better constant opt (&&, ||, ?:)
16- function pointers to forward reference (patch code generator) 18- add ELF executable and shared library output option (would be needed
19 for completness!).
17- add PowerPC code generator.20- add PowerPC code generator.
18- add portable byte code generator and interpreter.21- add portable byte code generator and interpreter for other
22 unsupported architectures.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t