History

spell fixes + texinfo format fixes by Peter Lund

bellard committed 23 years ago

Commit 3605c501 parent d5751371 file · +213 −132Browse files

Unified · Split

tcc-doc.texi+213−132
@@ -1,16 +1,48 @@
11 \input texinfo @c -*- texinfo -*-
2−
2+@c %**start of header
3+@setfilename tcc-doc.info
34 @settitle Tiny C Compiler Reference Documentation
5+@c %**end of header
6+
7+@include version.texi
8+
9+@ifinfo
10+Bla bla bla
11+@end ifinfo
12+
13+@iftex
414 @titlepage
15+@afourpaper
516 @sp 7
617 @center @titlefont{Tiny C Compiler Reference Documentation}
718 @sp 3
819 @end titlepage
20+@headings double
21+@end iftex
22+
23+@ifnothtml
24+@contents
25+@end ifnothtml
26+
27+@ifnottex
28+@node Top, Introduction, (dir), (dir)
29+@top Tiny C Compiler Reference Documentation
30+
31+This manual documents version @value{VERSION} of the Tiny C Compiler.
932
33+@menu
34+* Introduction:: Introduction to tcc.
35+* Invoke:: Invocation of tcc (command line, options).
36+* Bounds:: Automatic bounds-checking of C code.
37+* Libtcc:: bla bla bla.
38+@end menu
39+@end ifnottex
40+
41+@node Introduction
1042 @chapter Introduction
1143
1244 TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike other C
13−compilers, it is meant to be self-suffisant: you do not need an
45+compilers, it is meant to be self-relying: you do not need an
1446 external assembler or linker because TCC does that for you.
1547
1648 TCC compiles so @emph{fast} that even for big projects @code{Makefile}s may
@@ -24,13 +56,13 @@ that you run as a Perl or Python script. Compilation is so fast that · 7 unmodified lines
2456 your script will be as fast as if it was an executable.
2557
2658 TCC can also automatically generate memory and bound checks
27−(@xref{bounds}) while allowing all C pointers operations. TCC can do
59+(@pxref{Bounds}) while allowing all C pointers operations. TCC can do
2860 these checks even if non patched libraries are used.
2961
3062 With @code{libtcc}, you can use TCC as a backend for dynamic code
31−generation (@xref{libtcc}).
63+generation (@pxref{Libtcc}).
3264
33−@node invoke
65+@node Invoke
3466 @chapter Command line invocation
3567
3668 @section Quick start
@@ -41,45 +73,46 @@ usage: tcc [-c] [-o outfile] [-Bdir] [-bench] [-Idir] [-Dsym[=val]] [-Usym] · 4 unmodified lines
4173 [--] infile1 [infile2... --] [infile_args...]
4274 @end example
4375
44−TCC options are a very much like gcc. The main difference is that TCC
76+@noindent
77+TCC options are a very much like gcc options. The main difference is that TCC
4578 can also execute directly the resulting program and give it runtime
4679 arguments.
4780
4881 Here are some examples to understand the logic:
4982
5083 @table @code
51−@item tcc a.c
52−Compile a.c and execute it directly
84+@item @samp{tcc a.c}
85+Compile @file{a.c} and execute it directly
5386
54−@item tcc a.c arg1
87+@item @samp{tcc a.c arg1}
5588 Compile a.c and execute it directly. arg1 is given as first argument to
5689 the @code{main()} of a.c.
5790
58−@item tcc -- a.c b.c -- arg1
59−Compile a.c and b.c, link them together and execute them. arg1 is given
91+@item @samp{tcc -- a.c b.c -- arg1}
92+Compile @file{a.c} and @file{b.c}, link them together and execute them. arg1 is given
6093 as first argument to the @code{main()} of the resulting program. Because
61−multiple C files are specified, @code{--} are necessary to clearly separate the
94+multiple C files are specified, @option{--} are necessary to clearly separate the
6295 program arguments from the TCC options.
6396
64−@item tcc -o myprog a.c b.c
65−Compile a.c and b.c, link them and generate the executable myprog.
97+@item @samp{tcc -o myprog a.c b.c}
98+Compile @file{a.c} and @file{b.c}, link them and generate the executable @file{myprog}.
6699
67−@item tcc -o myprog a.o b.o
68−link a.o and b.o together and generate the executable myprog.
100+@item @samp{tcc -o myprog a.o b.o}
101+link @file{a.o} and @file{b.o} together and generate the executable @file{myprog}.
69102
70−@item tcc -c a.c
71−Compile a.c and generate object file a.o
103+@item @samp{tcc -c a.c}
104+Compile @file{a.c} and generate object file @file{a.o}.
72105
73−@item tcc -c asmfile.S
74−Preprocess with C preprocess and assemble asmfile.S and generate
75−object file asmfile.o.
106+@item @samp{tcc -c asmfile.S}
107+Preprocess with C preprocess and assemble @file{asmfile.S} and generate
108+object file @file{asmfile.o}.
76109
77−@item tcc -c asmfile.s
78−Assemble (but not preprocess) asmfile.s and generate object file
79−asmfile.o.
110+@item @samp{tcc -c asmfile.s}
111+Assemble (but not preprocess) @file{asmfile.s} and generate object file
112+@file{asmfile.o}.
80113
81−@item tcc -r -o ab.o a.c b.c
82−Compile a.c and b.c, link them together and generate the object file ab.o.
114+@item @samp{tcc -r -o ab.o a.c b.c}
115+Compile @file{a.c} and @file{b.c}, link them together and generate the object file @file{ab.o}.
83116
84117 @end table
85118
@@ -93,19 +126,19 @@ need to add @code{#!/usr/local/bin/tcc} at the start of your C source: · 7 unmodified lines
93126 #include <stdio.h>
94127
95128 int main()
96−{
129+@{
97130 printf("Hello World\n");
98131 return 0;
99−}
132+@}
100133 @end example
101134
102135 @section Option summary
103136
104137 General Options:
105138
106−@table @samp
139+@table @option
107140 @item -c
108−Generate an object file (@samp{-o} option must also be given).
141+Generate an object file (@option{-o} option must also be given).
109142
110143 @item -o outfile
111144 Put object file, executable, or dll into output file @file{outfile}.
@@ -120,54 +153,54 @@ Output compilation statistics. · 8 unmodified lines
120153
121154 Preprocessor options:
122155
123−@table @samp
156+@table @option
124157 @item -Idir
125−Specify an additionnal include path. Include paths are searched in the
158+Specify an additional include path. Include paths are searched in the
126159 order they are specified.
127160
128161 System include paths are always searched after. The default system
129162 include paths are: @file{/usr/local/include}, @file{/usr/include}
130−and @file{PREFIX/lib/tcc/include}. (@code{PREFIX} is usually
163+and @file{PREFIX/lib/tcc/include}. (@file{PREFIX} is usually
131164 @file{/usr} or @file{/usr/local}).
132165
133166 @item -Dsym[=val]
134−Define preprocessor symbol 'sym' to
135−val. If val is not present, its value is '1'. Function-like macros can
136−also be defined: @code{'-DF(a)=a+1'}
167+Define preprocessor symbol @samp{sym} to
168+val. If val is not present, its value is @samp{1}. Function-like macros can
169+also be defined: @option{-DF(a)=a+1}
137170
138171 @item -Usym
139−Undefine preprocessor symbol 'sym'.
172+Undefine preprocessor symbol @samp{sym}.
140173 @end table
141174
142175 Linker options:
143176
144−@table @samp
177+@table @option
145178 @item -Ldir
146−Specify an additionnal static library path for the @samp{-l} option. The
179+Specify an additional static library path for the @option{-l} option. The
147180 default library paths are @file{/usr/local/lib}, @file{/usr/lib} and @file{/lib}.
148181
149182 @item -lxxx
150183 Link your program with dynamic library libxxx.so or static library
151184 libxxx.a. The library is searched in the paths specified by the
152−@samp{-L} option.
185+@option{-L} option.
153186
154187 @item -shared
155−Generate a shared library instead of an executable (@samp{-o} option
188+Generate a shared library instead of an executable (@option{-o} option
156189 must also be given).
157190
158191 @item -static
159192 Generate a statically linked executable (default is a shared linked
160−executable) (@samp{-o} option must also be given).
193+executable) (@option{-o} option must also be given).
161194
162195 @item -r
163−Generate an object file combining all input files (@samp{-o} option must
196+Generate an object file combining all input files (@option{-o} option must
164197 also be given).
165198
166199 @end table
167200
168201 Debugger options:
169202
170−@table @samp
203+@table @option
171204 @item -g
172205 Generate run time debug information so that you get clear run time
173206 error messages: @code{ test.c:68: in function 'test5()': dereferencing
@@ -175,17 +208,17 @@ invalid pointer} instead of the laconic @code{Segmentation · 1 unmodified line
175208 fault}.
176209
177210 @item -b
178−Generate additionnal support code to check
179−memory allocations and array/pointer bounds. @samp{-g} is implied. Note
211+Generate additional support code to check
212+memory allocations and array/pointer bounds. @option{-g} is implied. Note
180213 that the generated code is slower and bigger in this case.
181214
182215 @item -bt N
183−Display N callers in stack traces. This is useful with @samp{-g} or
184−@samp{-b}.
216+Display N callers in stack traces. This is useful with @option{-g} or
217+@option{-b}.
185218
186219 @end table
187220
188−Note: GCC options @samp{-Ox}, @samp{-Wx}, @samp{-fx} and @samp{-mx} are
221+Note: GCC options @option{-Ox}, @option{-Wx}, @option{-fx} and @option{-mx} are
189222 ignored.
190223
191224 @chapter C language support
@@ -206,11 +239,11 @@ Currently implemented ISOC99 features: · 14 unmodified lines
206239
207240 @itemize
208241
209−@item 64 bit @code{'long long'} types are fully supported.
242+@item 64 bit @code{long long} types are fully supported.
210243
211−@item The boolean type @code{'_Bool'} is supported.
244+@item The boolean type @code{_Bool} is supported.
212245
213−@item @code{'__func__'} is a string variable containing the current
246+@item @code{__func__} is a string variable containing the current
214247 function name.
215248
216249 @item Variadic macros: @code{__VA_ARGS__} can be used for
@@ -218,6 +251,8 @@ function name. · 1 unmodified line
218251 @example
219252 #define dprintf(level, __VA_ARGS__) printf(__VA_ARGS__)
220253 @end example
254+
255+@noindent
221256 @code{dprintf} can then be used with a variable number of parameters.
222257
223258 @item Declarations can appear anywhere in a block (as in C++).
@@ -225,14 +260,14 @@ function name. · 1 unmodified line
225260 @item Array and struct/union elements can be initialized in any order by
226261 using designators:
227262 @example
228− struct { int x, y; } st[10] = { [0].x = 1, [0].y = 2 };
263+ struct @{ int x, y; @} st[10] = @{ [0].x = 1, [0].y = 2 @};
229264
230− int tab[10] = { 1, 2, [5] = 5, [9] = 9};
265+ int tab[10] = @{ 1, 2, [5] = 5, [9] = 9@};
231266 @end example
232267
233268 @item Compound initializers are supported:
234269 @example
235− int *p = (int []){ 1, 2, 3 };
270+ int *p = (int [])@{ 1, 2, 3 @};
236271 @end example
237272 to initialize a pointer pointing to an initialized array. The same
238273 works for structures and strings.
@@ -241,14 +276,16 @@ works for structures and strings. · 2 unmodified lines
241276 @example
242277 double d = 0x1234p10;
243278 @end example
279+
280+@noindent
244281 is the same as writing
245282 @example
246283 double d = 4771840.0;
247284 @end example
248285
249−@item @code{'inline'} keyword is ignored.
286+@item @code{inline} keyword is ignored.
250287
251−@item @code{'restrict'} keyword is ignored.
288+@item @code{restrict} keyword is ignored.
252289 @end itemize
253290
254291 @section GNU C extensions
@@ -259,30 +296,30 @@ TCC implements some GNU C extensions: · 4 unmodified lines
259296
260297 @item array designators can be used without '=':
261298 @example
262− int a[10] = { [0] 1, [5] 2, 3, 4 };
299+ int a[10] = @{ [0] 1, [5] 2, 3, 4 @};
263300 @end example
264301
265302 @item Structure field designators can be a label:
266303 @example
267− struct { int x, y; } st = { x: 1, y: 1};
304+ struct @{ int x, y; @} st = @{ x: 1, y: 1@};
268305 @end example
269306 instead of
270307 @example
271− struct { int x, y; } st = { .x = 1, .y = 1};
308+ struct @{ int x, y; @} st = @{ .x = 1, .y = 1@};
272309 @end example
273310
274−@item @code{'\e'} is ASCII character 27.
311+@item @code{\e} is ASCII character 27.
275312
276313 @item case ranges : ranges can be used in @code{case}s:
277314 @example
278− switch(a) {
279− case 1 ... 9:
315+ switch(a) @{
316+ case 1 @dots{} 9:
280317 printf("range 1 to 9\n");
281318 break;
282319 default:
283320 printf("unexpected\n");
284321 break;
285− }
322+ @}
286323 @end example
287324
288325 @item The keyword @code{__attribute__} is handled to specify variable or
@@ -307,20 +344,22 @@ Here are some examples: · 18 unmodified lines
307344 int a __attribute__ ((aligned(8), section(".mysection")));
308345 @end example
309346
310−align variable @code{'a'} to 8 bytes and put it in section @code{.mysection}.
347+@noindent
348+align variable @code{a} to 8 bytes and put it in section @code{.mysection}.
311349
312350 @example
313351 int my_add(int a, int b) __attribute__ ((section(".mycodesection")))
314− {
352+ @{
315353 return a + b;
316− }
354+ @}
317355 @end example
318356
319−generate function @code{'my_add'} in section @code{.mycodesection}.
357+@noindent
358+generate function @code{my_add} in section @code{.mycodesection}.
320359
321360 @item GNU style variadic macros:
322361 @example
323− #define dprintf(fmt, args...) printf(fmt, ## args)
362+ #define dprintf(fmt, args@dots{}) printf(fmt, ## args)
324363
325364 dprintf("no arg\n");
326365 dprintf("one arg %d\n", 1);
@@ -341,26 +380,31 @@ to get the alignment of a type or an expression. · 14 unmodified lines
341380 used to jump on the pointer resulting from @code{expr}.
342381
343382 @item Inline assembly with asm instruction:
383+@cindex inline assembly
384+@cindex assembly, inline
385+@cindex __asm__
344386 @example
345387 static inline void * my_memcpy(void * to, const void * from, size_t n)
346−{
388+@{
347389 int d0, d1, d2;
348390 __asm__ __volatile__(
349− "rep ; movsl\n\t"
350− "testb $2,%b4\n\t"
351− "je 1f\n\t"
352− "movsw\n"
353− "1:\ttestb $1,%b4\n\t"
354− "je 2f\n\t"
355− "movsb\n"
356− "2:"
357− : "=&c" (d0), "=&D" (d1), "=&S" (d2)
358− :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
359− : "memory");
391+ "rep ; movsl\n\t"
392+ "testb $2,%b4\n\t"
393+ "je 1f\n\t"
394+ "movsw\n"
395+ "1:\ttestb $1,%b4\n\t"
396+ "je 2f\n\t"
397+ "movsb\n"
398+ "2:"
399+ : "=&c" (d0), "=&D" (d1), "=&S" (d2)
400+ :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
401+ : "memory");
360402 return (to);
361−}
403+@}
362404 @end example
363405
406+@noindent
407+@cindex gas
364408 TCC includes its own x86 inline assembler with a @code{gas}-like (GNU
365409 assembler) syntax. No intermediate files are generated. GCC 3.x named
366410 operands are supported.
@@ -371,13 +415,13 @@ operands are supported. · 4 unmodified lines
371415
372416 @itemize
373417
374−@item @code{__TINYC__} is a predefined macro to @code{'1'} to
418+@item @code{__TINYC__} is a predefined macro to @code{1} to
375419 indicate that you use TCC.
376420
377−@item @code{'#!'} at the start of a line is ignored to allow scripting.
421+@item @code{#!} at the start of a line is ignored to allow scripting.
378422
379−@item Binary digits can be entered (@code{'0b101'} instead of
380−@code{'5'}).
423+@item Binary digits can be entered (@code{0b101} instead of
424+@code{5}).
381425
382426 @item @code{__BOUNDS_CHECKING_ON} is defined if bound checking is activated.
383427
@@ -452,6 +496,16 @@ They can be defined several times in the same source. Use 'b' · 68 unmodified lines
452496 @end itemize
453497
454498 @section Directives
499+@cindex assembler directives
500+@cindex directives, assembler
501+@cindex .align
502+@cindex .skip
503+@cindex .space
504+@cindex .byte
505+@cindex .word
506+@cindex .short
507+@cindex .int
508+@cindex .long
455509
456510 All directives are preceeded by a '.'. The following directives are
457511 supported:
@@ -468,6 +522,7 @@ supported: · 10 unmodified lines
468522 @end itemize
469523
470524 @section X86 Assembler
525+@cindex assembler
471526
472527 All X86 opcodes are supported. Only ATT syntax is supported (source
473528 then destination operand order). If no size suffix is given, TinyCC
@@ -476,20 +531,22 @@ tries to guess it from the operand sizes. · 2 unmodified lines
476531 Currently, MMX opcodes are supported but not SSE ones.
477532
478533 @chapter TinyCC Linker
534+@cindex linker
479535
480536 @section ELF file generation
537+@cindex ELF
481538
482539 TCC can directly output relocatable ELF files (object files),
483540 executable ELF files and dynamic ELF libraries without relying on an
484541 external linker.
485542
486543 Dynamic ELF libraries can be output but the C compiler does not generate
487−position independant code (PIC) code. It means that the dynamic librairy
544+position independent code (PIC). It means that the dynamic librairy
488545 code generated by TCC cannot be factorized among processes yet.
489546
490−TCC linker cannot currently suppress unused object code. But TCC
547+TCC linker cannot currently eliminate unused object code. But TCC
491548 will soon integrate a novel feature not found in GNU tools: unused code
492−will be suppressed at the function or variable level, provided you only
549+will be eliminated at the function or variable level, provided you only
493550 use TCC to compile your files.
494551
495552 @section ELF file loader
@@ -498,10 +555,14 @@ TCC can load ELF object files, archives (.a files) and dynamic · 2 unmodified lines
498555 libraries (.so).
499556
500557 @section GNU Linker Scripts
558+@cindex scripts, linker
559+@cindex linker scripts
560+@cindex GROUP, linker command
561+@cindex FILE, linker command
501562
502563 Because on many Linux systems some dynamic libraries (such as
503564 @file{/usr/lib/libc.so}) are in fact GNU ld link scripts (horrible!),
504−TCC linker also support a subset of GNU ld scripts.
565+the TCC linker also supports a subset of GNU ld scripts.
505566
506567 The @code{GROUP} and @code{FILE} commands are supported.
507568
@@ -513,78 +574,80 @@ Example from @file{/usr/lib/libc.so}: · 5 unmodified lines
513574 GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a )
514575 @end example
515576
516−@node bounds
577+@node Bounds
517578 @chapter TinyCC Memory and Bound checks
579+@cindex bound checks
580+@cindex memory checks
518581
519−This feature is activated with the @code{'-b'} (@xref{invoke}).
582+This feature is activated with the @option{-b} (@pxref{Invoke}).
520583
521584 Note that pointer size is @emph{unchanged} and that code generated
522585 with bound checks is @emph{fully compatible} with unchecked
523586 code. When a pointer comes from unchecked code, it is assumed to be
524587 valid. Even very obscure C code with casts should work correctly.
525588
526−To have more information about the ideas behind this method, check at
589+For more information about the ideas behind this method, see
527590 @url{http://www.doc.ic.ac.uk/~phjk/BoundsChecking.html}.
528591
529−Here are some examples of catched errors:
592+Here are some examples of caught errors:
530593
531594 @table @asis
532595
533596 @item Invalid range with standard string function:
534597 @example
535−{
598+@{
536599 char tab[10];
537600 memset(tab, 0, 11);
538−}
601+@}
539602 @end example
540603
541−@item Bound error in global or local arrays:
604+@item Out of bounds-error in global or local arrays:
542605 @example
543−{
606+@{
544607 int tab[10];
545− for(i=0;i<11;i++) {
608+ for(i=0;i<11;i++) @{
546609 sum += tab[i];
547− }
548−}
610+ @}
611+@}
549612 @end example
550613
551−@item Bound error in allocated data:
614+@item Out of bounds-error in malloc'ed data:
552615 @example
553−{
616+@{
554617 int *tab;
555618 tab = malloc(20 * sizeof(int));
556− for(i=0;i<21;i++) {
619+ for(i=0;i<21;i++) @{
557620 sum += tab4[i];
558− }
621+ @}
559622 free(tab);
560−}
623+@}
561624 @end example
562625
563−@item Access to a freed region:
626+@item Access of freed memory:
564627 @example
565−{
628+@{
566629 int *tab;
567630 tab = malloc(20 * sizeof(int));
568631 free(tab);
569− for(i=0;i<20;i++) {
632+ for(i=0;i<20;i++) @{
570633 sum += tab4[i];
571− }
572−}
634+ @}
635+@}
573636 @end example
574637
575−@item Freeing an already freed region:
638+@item Double free:
576639 @example
577−{
640+@{
578641 int *tab;
579642 tab = malloc(20 * sizeof(int));
580643 free(tab);
581644 free(tab);
582−}
645+@}
583646 @end example
584647
585648 @end table
586649
587−@node libtcc
650+@node Libtcc
588651 @chapter The @code{libtcc} library
589652
590653 The @code{libtcc} library enables you to use TCC as a backend for
@@ -597,7 +660,7 @@ The idea consists in giving a C string containing the program you want · 6 unmodified lines
597660 to compile directly to @code{libtcc}. Then you can access to any global
598661 symbol (function or variable) defined.
599662
600−@chapter Developper's guide
663+@chapter Developer's guide
601664
602665 This chapter gives some hints to understand how TCC works. You can skip
603666 it if you do not intend to modify the TCC code.
@@ -617,7 +680,7 @@ expansion. · 13 unmodified lines
617680
618681 @code{tok} contains the current token (see @code{TOK_xxx})
619682 constants. Identifiers and keywords are also keywords. @code{tokc}
620−contains additionnal infos about the token (for example a constant value
683+contains additional infos about the token (for example a constant value
621684 if number or string token).
622685
623686 @section Parser
@@ -771,22 +834,24 @@ contain the exported symbols (currently only used for debugging). · 147 unmodified lines
771834 @end table
772835
773836 @section Code generation
837+@cindex code generation
774838
775839 @subsection Introduction
776840
777841 The TCC code generator directly generates linked binary code in one
778842 pass. It is rather unusual these days (see gcc for example which
779−generates text assembly), but it allows to be very fast and surprisingly
780−not so complicated.
843+generates text assembly), but it can be very fast and surprisingly
844+little complicated.
781845
782846 The TCC code generator is register based. Optimization is only done at
783847 the expression level. No intermediate representation of expression is
784848 kept except the current values stored in the @emph{value stack}.
785849
786850 On x86, three temporary registers are used. When more registers are
787−needed, one register is flushed in a new local variable.
851+needed, one register is spilled into a new temporary variable on the stack.
788852
789853 @subsection The value stack
854+@cindex value stack, introduction
790855
791856 When an expression is parsed, its value is pushed on the value stack
792857 (@var{vstack}). The top of the value stack is @var{vtop}. Each value
@@ -794,7 +859,7 @@ stack entry is the structure @code{SValue}. · 1 unmodified line
794859
795860 @code{SValue.t} is the type. @code{SValue.r} indicates how the value is
796861 currently stored in the generated code. It is usually a CPU register
797−index (@code{REG_xxx} constants), but additionnal values and flags are
862+index (@code{REG_xxx} constants), but additional values and flags are
798863 defined:
799864
800865 @example
@@ -835,8 +900,8 @@ put in a normal register. · 34 unmodified lines
835900
836901 @item VT_JMP
837902 @itemx VT_JMPI
838−indicates that the value is the consequence of a jmp. For VT_JMP, it is
839−1 if the jump is taken, 0 otherwise. For VT_JMPI it is inverted.
903+indicates that the value is the consequence of a conditional jump. For VT_JMP,
904+it is 1 if the jump is taken, 0 otherwise. For VT_JMPI it is inverted.
840905
841906 These values are used to compile the @code{||} and @code{&&} logical
842907 operators.
@@ -857,10 +922,10 @@ understand how TCC works. · 14 unmodified lines
857922 @itemx VT_LVAL_SHORT
858923 @itemx VT_LVAL_UNSIGNED
859924 if the lvalue has an integer type, then these flags give its real
860−type. The type alone is not suffisant in case of cast optimisations.
925+type. The type alone is not enough in case of cast optimisations.
861926
862927 @item VT_LLOCAL
863−is a saved lvalue on the stack. @code{VT_LLOCAL} should be suppressed
928+is a saved lvalue on the stack. @code{VT_LLOCAL} should be eliminated
864929 ASAP because its semantics are rather complicated.
865930
866931 @item VT_MUSTCAST
@@ -877,17 +942,18 @@ are only used for optional bound checking. · 10 unmodified lines
877942 @end table
878943
879944 @subsection Manipulating the value stack
945+@cindex value stack
880946
881947 @code{vsetc()} and @code{vset()} pushes a new value on the value
882−stack. If the previous @code{vtop} was stored in a very unsafe place(for
948+stack. If the previous @var{vtop} was stored in a very unsafe place(for
883949 example in the CPU flags), then some code is generated to put the
884−previous @code{vtop} in a safe storage.
950+previous @var{vtop} in a safe storage.
885951
886−@code{vpop()} pops @code{vtop}. In some cases, it also generates cleanup
952+@code{vpop()} pops @var{vtop}. In some cases, it also generates cleanup
887953 code (for example if stacked floating point registers are used as on
888954 x86).
889955
890−The @code{gv(rc)} function generates code to evaluate @code{vtop} (the
956+The @code{gv(rc)} function generates code to evaluate @var{vtop} (the
891957 top value of the stack) into registers. @var{rc} selects in which
892958 register class the value should be put. @code{gv()} is the @emph{most
893959 important function} of the code generator.
@@ -896,7 +962,7 @@ important function} of the code generator. · 2 unmodified lines
896962 entries.
897963
898964 @subsection CPU dependent code generation
899−
965+@cindex CPU dependent
900966 See the @file{i386-gen.c} file to have an example.
901967
902968 @table @code
@@ -939,12 +1005,18 @@ floating point to floating point of different size conversion. · 36 unmodified lines
9391005
9401006 @item gen_bounded_ptr_add()
9411007 @item gen_bounded_ptr_deref()
942−are only used for bound checking.
1008+are only used for bounds checking.
9431009
9441010 @end table
9451011
9461012 @section Optimizations done
947−
1013+@cindex optimizations
1014+@cindex constant propagation
1015+@cindex strength reduction
1016+@cindex comparison operators
1017+@cindex caching processor flags
1018+@cindex flags, caching
1019+@cindex jump optimization
9481020 Constant propagation is done for all operations. Multiplications and
9491021 divisions are optimized to shifts when appropriate. Comparison
9501022 operators are optimized by maintaining a special cache for the
@@ -952,3 +1024,12 @@ processor flags. &&, || and ! are optimized by maintaining a special · 1 unmodified line
9521024 'jump target' value. No other jump optimization is currently performed
9531025 because it would require to store the code in a more abstract fashion.
9541026
1027+@unnumbered Concept Index
1028+@printindex cp
1029+
1030+@bye
1031+
1032+@c Local variables:
1033+@c fill-column: 78
1034+@c texinfo-column-for-description: 32
1035+@c End:

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