tcc-doc.html 92 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331
  1. <HTML>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  3. <!-- Created on March, 22 2008 by texi2html 1.64 -->
  4. <!--
  5. Written by: Lionel Cons <[email protected]> (original author)
  6. Karl Berry <[email protected]>
  7. Olaf Bachmann <[email protected]>
  8. and many others.
  9. Maintained by: Olaf Bachmann <[email protected]>
  10. Send bugs and suggestions to <[email protected]>
  11. -->
  12. <HEAD>
  13. <TITLE>Tiny C Compiler Reference Documentation: </TITLE>
  14. <META NAME="description" CONTENT="Tiny C Compiler Reference Documentation: ">
  15. <META NAME="keywords" CONTENT="Tiny C Compiler Reference Documentation: ">
  16. <META NAME="resource-type" CONTENT="document">
  17. <META NAME="distribution" CONTENT="global">
  18. <META NAME="Generator" CONTENT="texi2html 1.64">
  19. </HEAD>
  20. <BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
  21. <A NAME="SEC1"></A>
  22. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  23. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> &lt; </A>]</TD>
  24. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> &gt; </A>]</TD>
  25. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  26. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  27. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  28. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  29. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  30. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  31. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  32. </TR></TABLE>
  33. <P>
  34. <A NAME="Introduction"></A>
  35. <H1> 1. Introduction </H1>
  36. <!--docid::SEC1::-->
  37. <P>
  38. TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike other C
  39. compilers, it is meant to be self-relying: you do not need an
  40. external assembler or linker because TCC does that for you.
  41. </P><P>
  42. TCC compiles so <EM>fast</EM> that even for big projects <CODE>Makefile</CODE>s may
  43. not be necessary.
  44. </P><P>
  45. TCC not only supports ANSI C, but also most of the new ISO C99
  46. standard and many GNUC extensions including inline assembly.
  47. </P><P>
  48. TCC can also be used to make <EM>C scripts</EM>, i.e. pieces of C source
  49. that you run as a Perl or Python script. Compilation is so fast that
  50. your script will be as fast as if it was an executable.
  51. </P><P>
  52. TCC can also automatically generate memory and bound checks
  53. (see section <A HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A>) while allowing all C pointers operations. TCC can do
  54. these checks even if non patched libraries are used.
  55. </P><P>
  56. With <CODE>libtcc</CODE>, you can use TCC as a backend for dynamic code
  57. generation (see section <A HREF="tcc-doc.html#SEC22">7. The <CODE>libtcc</CODE> library</A>).
  58. </P><P>
  59. TCC mainly supports the i386 target on Linux and Windows. There are alpha
  60. ports for the ARM (<CODE>arm-tcc</CODE>) and the TMS320C67xx targets
  61. (<CODE>c67-tcc</CODE>). More information about the ARM port is available at
  62. <A HREF="http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html">http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html</A>.
  63. </P><P>
  64. <A NAME="Invoke"></A>
  65. <HR SIZE="6">
  66. <A NAME="SEC2"></A>
  67. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  68. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> &lt; </A>]</TD>
  69. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC3"> &gt; </A>]</TD>
  70. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  71. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  72. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  73. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  74. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  75. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  76. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  77. </TR></TABLE>
  78. <H1> 2. Command line invocation </H1>
  79. <!--docid::SEC2::-->
  80. <P>
  81. [This manual documents version 0.9.24 of the Tiny C Compiler]
  82. </P><P>
  83. <HR SIZE="6">
  84. <A NAME="SEC3"></A>
  85. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  86. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC2"> &lt; </A>]</TD>
  87. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC4"> &gt; </A>]</TD>
  88. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  89. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  90. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  91. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  92. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  93. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  94. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  95. </TR></TABLE>
  96. <H2> 2.1 Quick start </H2>
  97. <!--docid::SEC3::-->
  98. <P>
  99. <TABLE><tr><td>&nbsp;</td><td class=example><pre>usage: tcc [options] [<VAR>infile1</VAR> <VAR>infile2</VAR><small>...</small>] [<SAMP>`-run'</SAMP> <VAR>infile</VAR> <VAR>args</VAR><small>...</small>]
  100. </pre></td></tr></table></P><P>
  101. TCC options are a very much like gcc options. The main difference is that TCC
  102. can also execute directly the resulting program and give it runtime
  103. arguments.
  104. </P><P>
  105. Here are some examples to understand the logic:
  106. </P><P>
  107. <DL COMPACT>
  108. <DT><CODE><SAMP>`tcc -run a.c'</SAMP></CODE>
  109. <DD>Compile <TT>`a.c'</TT> and execute it directly
  110. <P>
  111. <DT><CODE><SAMP>`tcc -run a.c arg1'</SAMP></CODE>
  112. <DD>Compile a.c and execute it directly. arg1 is given as first argument to
  113. the <CODE>main()</CODE> of a.c.
  114. <P>
  115. <DT><CODE><SAMP>`tcc a.c -run b.c arg1'</SAMP></CODE>
  116. <DD>Compile <TT>`a.c'</TT> and <TT>`b.c'</TT>, link them together and execute them. arg1 is given
  117. as first argument to the <CODE>main()</CODE> of the resulting program. Because
  118. multiple C files are specified, <SAMP>`--'</SAMP> are necessary to clearly separate the
  119. program arguments from the TCC options.
  120. <P>
  121. <DT><CODE><SAMP>`tcc -o myprog a.c b.c'</SAMP></CODE>
  122. <DD>Compile <TT>`a.c'</TT> and <TT>`b.c'</TT>, link them and generate the executable <TT>`myprog'</TT>.
  123. <P>
  124. <DT><CODE><SAMP>`tcc -o myprog a.o b.o'</SAMP></CODE>
  125. <DD>link <TT>`a.o'</TT> and <TT>`b.o'</TT> together and generate the executable <TT>`myprog'</TT>.
  126. <P>
  127. <DT><CODE><SAMP>`tcc -c a.c'</SAMP></CODE>
  128. <DD>Compile <TT>`a.c'</TT> and generate object file <TT>`a.o'</TT>.
  129. <P>
  130. <DT><CODE><SAMP>`tcc -c asmfile.S'</SAMP></CODE>
  131. <DD>Preprocess with C preprocess and assemble <TT>`asmfile.S'</TT> and generate
  132. object file <TT>`asmfile.o'</TT>.
  133. <P>
  134. <DT><CODE><SAMP>`tcc -c asmfile.s'</SAMP></CODE>
  135. <DD>Assemble (but not preprocess) <TT>`asmfile.s'</TT> and generate object file
  136. <TT>`asmfile.o'</TT>.
  137. <P>
  138. <DT><CODE><SAMP>`tcc -r -o ab.o a.c b.c'</SAMP></CODE>
  139. <DD>Compile <TT>`a.c'</TT> and <TT>`b.c'</TT>, link them together and generate the object file <TT>`ab.o'</TT>.
  140. <P>
  141. </DL>
  142. <P>
  143. Scripting:
  144. </P><P>
  145. TCC can be invoked from <EM>scripts</EM>, just as shell scripts. You just
  146. need to add <CODE>#!/usr/local/bin/tcc -run</CODE> at the start of your C source:
  147. </P><P>
  148. <TABLE><tr><td>&nbsp;</td><td class=example><pre>#!/usr/local/bin/tcc -run
  149. #include &#60;stdio.h&#62;
  150. int main()
  151. {
  152. printf("Hello World\n");
  153. return 0;
  154. }
  155. </pre></td></tr></table></P><P>
  156. <HR SIZE="6">
  157. <A NAME="SEC4"></A>
  158. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  159. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC3"> &lt; </A>]</TD>
  160. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> &gt; </A>]</TD>
  161. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  162. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  163. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  164. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  165. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  166. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  167. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  168. </TR></TABLE>
  169. <H2> 2.2 Option summary </H2>
  170. <!--docid::SEC4::-->
  171. <P>
  172. General Options:
  173. </P><P>
  174. <DL COMPACT>
  175. <DT><SAMP>`-v'</SAMP>
  176. <DD>Display current TCC version.
  177. <P>
  178. <DT><SAMP>`-c'</SAMP>
  179. <DD>Generate an object file (<SAMP>`-o'</SAMP> option must also be given).
  180. <P>
  181. <DT><SAMP>`-o outfile'</SAMP>
  182. <DD>Put object file, executable, or dll into output file <TT>`outfile'</TT>.
  183. <P>
  184. <DT><SAMP>`-Bdir'</SAMP>
  185. <DD>Set the path where the tcc internal libraries can be found (default is
  186. <TT>`PREFIX/lib/tcc'</TT>).
  187. <P>
  188. <DT><SAMP>`-bench'</SAMP>
  189. <DD>Output compilation statistics.
  190. <P>
  191. <DT><SAMP>`-run source [args...]'</SAMP>
  192. <DD><P>
  193. Compile file <VAR>source</VAR> and run it with the command line arguments
  194. <VAR>args</VAR>. In order to be able to give more than one argument to a
  195. script, several TCC options can be given <EM>after</EM> the
  196. <SAMP>`-run'</SAMP> option, separated by spaces. Example:
  197. </P><P>
  198. <TABLE><tr><td>&nbsp;</td><td class=example><pre>tcc "-run -L/usr/X11R6/lib -lX11" ex4.c
  199. </pre></td></tr></table></P><P>
  200. In a script, it gives the following header:
  201. </P><P>
  202. <TABLE><tr><td>&nbsp;</td><td class=example><pre>#!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11
  203. #include &#60;stdlib.h&#62;
  204. int main(int argc, char **argv)
  205. {
  206. ...
  207. }
  208. </pre></td></tr></table></P><P>
  209. </DL>
  210. <P>
  211. Preprocessor options:
  212. </P><P>
  213. <DL COMPACT>
  214. <DT><SAMP>`-Idir'</SAMP>
  215. <DD>Specify an additional include path. Include paths are searched in the
  216. order they are specified.
  217. <P>
  218. System include paths are always searched after. The default system
  219. include paths are: <TT>`/usr/local/include'</TT>, <TT>`/usr/include'</TT>
  220. and <TT>`PREFIX/lib/tcc/include'</TT>. (<TT>`PREFIX'</TT> is usually
  221. <TT>`/usr'</TT> or <TT>`/usr/local'</TT>).
  222. </P><P>
  223. <DT><SAMP>`-Dsym[=val]'</SAMP>
  224. <DD>Define preprocessor symbol <SAMP>`sym'</SAMP> to
  225. val. If val is not present, its value is <SAMP>`1'</SAMP>. Function-like macros can
  226. also be defined: <SAMP>`-DF(a)=a+1'</SAMP>
  227. <P>
  228. <DT><SAMP>`-Usym'</SAMP>
  229. <DD>Undefine preprocessor symbol <SAMP>`sym'</SAMP>.
  230. </DL>
  231. <P>
  232. Compilation flags:
  233. </P><P>
  234. Note: each of the following warning options has a negative form beginning with
  235. <SAMP>`-fno-'</SAMP>.
  236. </P><P>
  237. <DL COMPACT>
  238. <DT><SAMP>`-funsigned-char'</SAMP>
  239. <DD>Let the <CODE>char</CODE> type be unsigned.
  240. <P>
  241. <DT><SAMP>`-fsigned-char'</SAMP>
  242. <DD>Let the <CODE>char</CODE> type be signed.
  243. <P>
  244. <DT><SAMP>`-fno-common'</SAMP>
  245. <DD>Do not generate common symbols for uninitialized data.
  246. <P>
  247. <DT><SAMP>`-fleading-underscore'</SAMP>
  248. <DD>Add a leading underscore at the beginning of each C symbol.
  249. <P>
  250. </DL>
  251. <P>
  252. Warning options:
  253. </P><P>
  254. <DL COMPACT>
  255. <DT><SAMP>`-w'</SAMP>
  256. <DD>Disable all warnings.
  257. <P>
  258. </DL>
  259. <P>
  260. Note: each of the following warning options has a negative form beginning with
  261. <SAMP>`-Wno-'</SAMP>.
  262. </P><P>
  263. <DL COMPACT>
  264. <DT><SAMP>`-Wimplicit-function-declaration'</SAMP>
  265. <DD>Warn about implicit function declaration.
  266. <P>
  267. <DT><SAMP>`-Wunsupported'</SAMP>
  268. <DD>Warn about unsupported GCC features that are ignored by TCC.
  269. <P>
  270. <DT><SAMP>`-Wwrite-strings'</SAMP>
  271. <DD>Make string constants be of type <CODE>const char *</CODE> instead of <CODE>char
  272. *</CODE>.
  273. <P>
  274. <DT><SAMP>`-Werror'</SAMP>
  275. <DD>Abort compilation if warnings are issued.
  276. <P>
  277. <DT><SAMP>`-Wall'</SAMP>
  278. <DD>Activate all warnings, except <SAMP>`-Werror'</SAMP>, <SAMP>`-Wunusupported'</SAMP> and
  279. <SAMP>`-Wwrite-strings'</SAMP>.
  280. <P>
  281. </DL>
  282. <P>
  283. Linker options:
  284. </P><P>
  285. <DL COMPACT>
  286. <DT><SAMP>`-Ldir'</SAMP>
  287. <DD>Specify an additional static library path for the <SAMP>`-l'</SAMP> option. The
  288. default library paths are <TT>`/usr/local/lib'</TT>, <TT>`/usr/lib'</TT> and <TT>`/lib'</TT>.
  289. <P>
  290. <DT><SAMP>`-lxxx'</SAMP>
  291. <DD>Link your program with dynamic library libxxx.so or static library
  292. libxxx.a. The library is searched in the paths specified by the
  293. <SAMP>`-L'</SAMP> option.
  294. <P>
  295. <DT><SAMP>`-shared'</SAMP>
  296. <DD>Generate a shared library instead of an executable (<SAMP>`-o'</SAMP> option
  297. must also be given).
  298. <P>
  299. <DT><SAMP>`-static'</SAMP>
  300. <DD>Generate a statically linked executable (default is a shared linked
  301. executable) (<SAMP>`-o'</SAMP> option must also be given).
  302. <P>
  303. <DT><SAMP>`-rdynamic'</SAMP>
  304. <DD>Export global symbols to the dynamic linker. It is useful when a library
  305. opened with <CODE>dlopen()</CODE> needs to access executable symbols.
  306. <P>
  307. <DT><SAMP>`-r'</SAMP>
  308. <DD>Generate an object file combining all input files (<SAMP>`-o'</SAMP> option must
  309. also be given).
  310. <P>
  311. <DT><SAMP>`-Wl,-Ttext,address'</SAMP>
  312. <DD>Set the start of the .text section to <VAR>address</VAR>.
  313. <P>
  314. <DT><SAMP>`-Wl,--oformat,fmt'</SAMP>
  315. <DD>Use <VAR>fmt</VAR> as output format. The supported output formats are:
  316. <DL COMPACT>
  317. <DT><CODE>elf32-i386</CODE>
  318. <DD>ELF output format (default)
  319. <DT><CODE>binary</CODE>
  320. <DD>Binary image (only for executable output)
  321. <DT><CODE>coff</CODE>
  322. <DD>COFF output format (only for executable output for TMS320C67xx target)
  323. </DL>
  324. <P>
  325. </DL>
  326. <P>
  327. Debugger options:
  328. </P><P>
  329. <DL COMPACT>
  330. <DT><SAMP>`-g'</SAMP>
  331. <DD>Generate run time debug information so that you get clear run time
  332. error messages: <CODE> test.c:68: in function 'test5()': dereferencing
  333. invalid pointer</CODE> instead of the laconic <CODE>Segmentation
  334. fault</CODE>.
  335. <P>
  336. <DT><SAMP>`-b'</SAMP>
  337. <DD>Generate additional support code to check
  338. memory allocations and array/pointer bounds. <SAMP>`-g'</SAMP> is implied. Note
  339. that the generated code is slower and bigger in this case.
  340. <P>
  341. <DT><SAMP>`-bt N'</SAMP>
  342. <DD>Display N callers in stack traces. This is useful with <SAMP>`-g'</SAMP> or
  343. <SAMP>`-b'</SAMP>.
  344. <P>
  345. </DL>
  346. <P>
  347. Note: GCC options <SAMP>`-Ox'</SAMP>, <SAMP>`-fx'</SAMP> and <SAMP>`-mx'</SAMP> are
  348. ignored.
  349. </P><P>
  350. <HR SIZE="6">
  351. <A NAME="SEC5"></A>
  352. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  353. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC4"> &lt; </A>]</TD>
  354. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC6"> &gt; </A>]</TD>
  355. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  356. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  357. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  358. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  359. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  360. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  361. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  362. </TR></TABLE>
  363. <H1> 3. C language support </H1>
  364. <!--docid::SEC5::-->
  365. <P>
  366. <HR SIZE="6">
  367. <A NAME="SEC6"></A>
  368. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  369. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> &lt; </A>]</TD>
  370. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC7"> &gt; </A>]</TD>
  371. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  372. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  373. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  374. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  375. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  376. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  377. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  378. </TR></TABLE>
  379. <H2> 3.1 ANSI C </H2>
  380. <!--docid::SEC6::-->
  381. <P>
  382. TCC implements all the ANSI C standard, including structure bit fields
  383. and floating point numbers (<CODE>long double</CODE>, <CODE>double</CODE>, and
  384. <CODE>float</CODE> fully supported).
  385. </P><P>
  386. <HR SIZE="6">
  387. <A NAME="SEC7"></A>
  388. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  389. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC6"> &lt; </A>]</TD>
  390. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC8"> &gt; </A>]</TD>
  391. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  392. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  393. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  394. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  395. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  396. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  397. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  398. </TR></TABLE>
  399. <H2> 3.2 ISOC99 extensions </H2>
  400. <!--docid::SEC7::-->
  401. <P>
  402. TCC implements many features of the new C standard: ISO C99. Currently
  403. missing items are: complex and imaginary numbers and variable length
  404. arrays.
  405. </P><P>
  406. Currently implemented ISOC99 features:
  407. </P><P>
  408. <UL>
  409. <LI>64 bit <CODE>long long</CODE> types are fully supported.
  410. <P>
  411. <LI>The boolean type <CODE>_Bool</CODE> is supported.
  412. <P>
  413. <LI><CODE>__func__</CODE> is a string variable containing the current
  414. function name.
  415. <P>
  416. <LI>Variadic macros: <CODE>__VA_ARGS__</CODE> can be used for
  417. function-like macros:
  418. <TABLE><tr><td>&nbsp;</td><td class=example><pre> #define dprintf(level, __VA_ARGS__) printf(__VA_ARGS__)
  419. </pre></td></tr></table><P>
  420. <CODE>dprintf</CODE> can then be used with a variable number of parameters.
  421. </P><P>
  422. <LI>Declarations can appear anywhere in a block (as in C++).
  423. <P>
  424. <LI>Array and struct/union elements can be initialized in any order by
  425. using designators:
  426. <TABLE><tr><td>&nbsp;</td><td class=example><pre> struct { int x, y; } st[10] = { [0].x = 1, [0].y = 2 };
  427. int tab[10] = { 1, 2, [5] = 5, [9] = 9};
  428. </pre></td></tr></table>
  429. <LI>Compound initializers are supported:
  430. <TABLE><tr><td>&nbsp;</td><td class=example><pre> int *p = (int []){ 1, 2, 3 };
  431. </pre></td></tr></table>to initialize a pointer pointing to an initialized array. The same
  432. works for structures and strings.
  433. <P>
  434. <LI>Hexadecimal floating point constants are supported:
  435. <TABLE><tr><td>&nbsp;</td><td class=example><pre> double d = 0x1234p10;
  436. </pre></td></tr></table><P>
  437. is the same as writing
  438. <TABLE><tr><td>&nbsp;</td><td class=example><pre> double d = 4771840.0;
  439. </pre></td></tr></table></P><P>
  440. <LI><CODE>inline</CODE> keyword is ignored.
  441. <P>
  442. <LI><CODE>restrict</CODE> keyword is ignored.
  443. </UL>
  444. <P>
  445. <HR SIZE="6">
  446. <A NAME="SEC8"></A>
  447. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  448. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC7"> &lt; </A>]</TD>
  449. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC9"> &gt; </A>]</TD>
  450. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  451. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  452. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  453. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  454. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  455. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  456. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  457. </TR></TABLE>
  458. <H2> 3.3 GNU C extensions </H2>
  459. <!--docid::SEC8::-->
  460. <P>
  461. TCC implements some GNU C extensions:
  462. </P><P>
  463. <UL>
  464. <LI>array designators can be used without '=':
  465. <TABLE><tr><td>&nbsp;</td><td class=example><pre> int a[10] = { [0] 1, [5] 2, 3, 4 };
  466. </pre></td></tr></table><P>
  467. <LI>Structure field designators can be a label:
  468. <TABLE><tr><td>&nbsp;</td><td class=example><pre> struct { int x, y; } st = { x: 1, y: 1};
  469. </pre></td></tr></table>instead of
  470. <TABLE><tr><td>&nbsp;</td><td class=example><pre> struct { int x, y; } st = { .x = 1, .y = 1};
  471. </pre></td></tr></table><P>
  472. <LI><CODE>\e</CODE> is ASCII character 27.
  473. <P>
  474. <LI>case ranges : ranges can be used in <CODE>case</CODE>s:
  475. <TABLE><tr><td>&nbsp;</td><td class=example><pre> switch(a) {
  476. case 1 <small>...</small> 9:
  477. printf("range 1 to 9\n");
  478. break;
  479. default:
  480. printf("unexpected\n");
  481. break;
  482. }
  483. </pre></td></tr></table><P>
  484. <LI>The keyword <CODE>__attribute__</CODE> is handled to specify variable or
  485. function attributes. The following attributes are supported:
  486. <UL>
  487. <LI><CODE>aligned(n)</CODE>: align a variable or a structure field to n bytes
  488. (must be a power of two).
  489. <LI><CODE>packed</CODE>: force alignment of a variable or a structure field to
  490. 1.
  491. <P>
  492. <LI><CODE>section(name)</CODE>: generate function or data in assembly section
  493. name (name is a string containing the section name) instead of the default
  494. section.
  495. <P>
  496. <LI><CODE>unused</CODE>: specify that the variable or the function is unused.
  497. <P>
  498. <LI><CODE>cdecl</CODE>: use standard C calling convention (default).
  499. <P>
  500. <LI><CODE>stdcall</CODE>: use Pascal-like calling convention.
  501. <P>
  502. <LI><CODE>regparm(n)</CODE>: use fast i386 calling convention. <VAR>n</VAR> must be
  503. between 1 and 3. The first <VAR>n</VAR> function parameters are respectively put in
  504. registers <CODE>%eax</CODE>, <CODE>%edx</CODE> and <CODE>%ecx</CODE>.
  505. <P>
  506. </UL>
  507. <P>
  508. Here are some examples:
  509. <TABLE><tr><td>&nbsp;</td><td class=example><pre> int a __attribute__ ((aligned(8), section(".mysection")));
  510. </pre></td></tr></table></P><P>
  511. align variable <CODE>a</CODE> to 8 bytes and put it in section <CODE>.mysection</CODE>.
  512. </P><P>
  513. <TABLE><tr><td>&nbsp;</td><td class=example><pre> int my_add(int a, int b) __attribute__ ((section(".mycodesection")))
  514. {
  515. return a + b;
  516. }
  517. </pre></td></tr></table></P><P>
  518. generate function <CODE>my_add</CODE> in section <CODE>.mycodesection</CODE>.
  519. </P><P>
  520. <LI>GNU style variadic macros:
  521. <TABLE><tr><td>&nbsp;</td><td class=example><pre> #define dprintf(fmt, args<small>...</small>) printf(fmt, ## args)
  522. dprintf("no arg\n");
  523. dprintf("one arg %d\n", 1);
  524. </pre></td></tr></table><P>
  525. <LI><CODE>__FUNCTION__</CODE> is interpreted as C99 <CODE>__func__</CODE>
  526. (so it has not exactly the same semantics as string literal GNUC
  527. where it is a string literal).
  528. <P>
  529. <LI>The <CODE>__alignof__</CODE> keyword can be used as <CODE>sizeof</CODE>
  530. to get the alignment of a type or an expression.
  531. <P>
  532. <LI>The <CODE>typeof(x)</CODE> returns the type of <CODE>x</CODE>.
  533. <CODE>x</CODE> is an expression or a type.
  534. <P>
  535. <LI>Computed gotos: <CODE>&#38;&#38;label</CODE> returns a pointer of type
  536. <CODE>void *</CODE> on the goto label <CODE>label</CODE>. <CODE>goto *expr</CODE> can be
  537. used to jump on the pointer resulting from <CODE>expr</CODE>.
  538. <P>
  539. <LI>Inline assembly with asm instruction:
  540. <A NAME="IDX1"></A>
  541. <A NAME="IDX2"></A>
  542. <A NAME="IDX3"></A>
  543. <TABLE><tr><td>&nbsp;</td><td class=example><pre>static inline void * my_memcpy(void * to, const void * from, size_t n)
  544. {
  545. int d0, d1, d2;
  546. __asm__ __volatile__(
  547. "rep ; movsl\n\t"
  548. "testb $2,%b4\n\t"
  549. "je 1f\n\t"
  550. "movsw\n"
  551. "1:\ttestb $1,%b4\n\t"
  552. "je 2f\n\t"
  553. "movsb\n"
  554. "2:"
  555. : "=&c" (d0), "=&#38;D" (d1), "=&#38;S" (d2)
  556. :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
  557. : "memory");
  558. return (to);
  559. }
  560. </pre></td></tr></table><P>
  561. <A NAME="IDX4"></A>
  562. TCC includes its own x86 inline assembler with a <CODE>gas</CODE>-like (GNU
  563. assembler) syntax. No intermediate files are generated. GCC 3.x named
  564. operands are supported.
  565. </P><P>
  566. <LI><CODE>__builtin_types_compatible_p()</CODE> and <CODE>__builtin_constant_p()</CODE>
  567. are supported.
  568. <P>
  569. <LI><CODE>#pragma pack</CODE> is supported for win32 compatibility.
  570. <P>
  571. </UL>
  572. <P>
  573. <HR SIZE="6">
  574. <A NAME="SEC9"></A>
  575. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  576. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC8"> &lt; </A>]</TD>
  577. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> &gt; </A>]</TD>
  578. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  579. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  580. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  581. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  582. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  583. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  584. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  585. </TR></TABLE>
  586. <H2> 3.4 TinyCC extensions </H2>
  587. <!--docid::SEC9::-->
  588. <P>
  589. <UL>
  590. <LI><CODE>__TINYC__</CODE> is a predefined macro to <CODE>1</CODE> to
  591. indicate that you use TCC.
  592. <P>
  593. <LI><CODE>#!</CODE> at the start of a line is ignored to allow scripting.
  594. <P>
  595. <LI>Binary digits can be entered (<CODE>0b101</CODE> instead of
  596. <CODE>5</CODE>).
  597. <P>
  598. <LI><CODE>__BOUNDS_CHECKING_ON</CODE> is defined if bound checking is activated.
  599. <P>
  600. </UL>
  601. <P>
  602. <HR SIZE="6">
  603. <A NAME="SEC10"></A>
  604. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  605. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC9"> &lt; </A>]</TD>
  606. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC11"> &gt; </A>]</TD>
  607. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  608. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  609. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  610. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  611. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  612. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  613. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  614. </TR></TABLE>
  615. <H1> 4. TinyCC Assembler </H1>
  616. <!--docid::SEC10::-->
  617. <P>
  618. Since version 0.9.16, TinyCC integrates its own assembler. TinyCC
  619. assembler supports a gas-like syntax (GNU assembler). You can
  620. desactivate assembler support if you want a smaller TinyCC executable
  621. (the C compiler does not rely on the assembler).
  622. </P><P>
  623. TinyCC Assembler is used to handle files with <TT>`.S'</TT> (C
  624. preprocessed assembler) and <TT>`.s'</TT> extensions. It is also used to
  625. handle the GNU inline assembler with the <CODE>asm</CODE> keyword.
  626. </P><P>
  627. <HR SIZE="6">
  628. <A NAME="SEC11"></A>
  629. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  630. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC10"> &lt; </A>]</TD>
  631. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC12"> &gt; </A>]</TD>
  632. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  633. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  634. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  635. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  636. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  637. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  638. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  639. </TR></TABLE>
  640. <H2> 4.1 Syntax </H2>
  641. <!--docid::SEC11::-->
  642. <P>
  643. TinyCC Assembler supports most of the gas syntax. The tokens are the
  644. same as C.
  645. </P><P>
  646. <UL>
  647. <LI>C and C++ comments are supported.
  648. <P>
  649. <LI>Identifiers are the same as C, so you cannot use '.' or '$'.
  650. <P>
  651. <LI>Only 32 bit integer numbers are supported.
  652. <P>
  653. </UL>
  654. <P>
  655. <HR SIZE="6">
  656. <A NAME="SEC12"></A>
  657. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  658. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC11"> &lt; </A>]</TD>
  659. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC13"> &gt; </A>]</TD>
  660. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  661. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  662. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  663. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  664. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  665. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  666. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  667. </TR></TABLE>
  668. <H2> 4.2 Expressions </H2>
  669. <!--docid::SEC12::-->
  670. <P>
  671. <UL>
  672. <LI>Integers in decimal, octal and hexa are supported.
  673. <P>
  674. <LI>Unary operators: +, -, ~.
  675. <P>
  676. <LI>Binary operators in decreasing priority order:
  677. <P>
  678. <OL>
  679. <LI>*, /, %
  680. <LI>&#38;, |, ^
  681. <LI>+, -
  682. </OL>
  683. <P>
  684. <LI>A value is either an absolute number or a label plus an offset.
  685. All operators accept absolute values except '+' and '-'. '+' or '-' can be
  686. used to add an offset to a label. '-' supports two labels only if they
  687. are the same or if they are both defined and in the same section.
  688. <P>
  689. </UL>
  690. <P>
  691. <HR SIZE="6">
  692. <A NAME="SEC13"></A>
  693. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  694. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC12"> &lt; </A>]</TD>
  695. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC14"> &gt; </A>]</TD>
  696. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  697. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  698. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  699. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  700. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  701. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  702. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  703. </TR></TABLE>
  704. <H2> 4.3 Labels </H2>
  705. <!--docid::SEC13::-->
  706. <P>
  707. <UL>
  708. <LI>All labels are considered as local, except undefined ones.
  709. <P>
  710. <LI>Numeric labels can be used as local <CODE>gas</CODE>-like labels.
  711. They can be defined several times in the same source. Use 'b'
  712. (backward) or 'f' (forward) as suffix to reference them:
  713. <P>
  714. <TABLE><tr><td>&nbsp;</td><td class=example><pre> 1:
  715. jmp 1b /* jump to '1' label before */
  716. jmp 1f /* jump to '1' label after */
  717. 1:
  718. </pre></td></tr></table></P><P>
  719. </UL>
  720. <P>
  721. <HR SIZE="6">
  722. <A NAME="SEC14"></A>
  723. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  724. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC13"> &lt; </A>]</TD>
  725. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC15"> &gt; </A>]</TD>
  726. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  727. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  728. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  729. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  730. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  731. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  732. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  733. </TR></TABLE>
  734. <H2> 4.4 Directives </H2>
  735. <!--docid::SEC14::-->
  736. <P>
  737. All directives are preceeded by a '.'. The following directives are
  738. supported:
  739. </P><P>
  740. <UL>
  741. <LI>.align n[,value]
  742. <LI>.skip n[,value]
  743. <LI>.space n[,value]
  744. <LI>.byte value1[,...]
  745. <LI>.word value1[,...]
  746. <LI>.short value1[,...]
  747. <LI>.int value1[,...]
  748. <LI>.long value1[,...]
  749. <LI>.quad immediate_value1[,...]
  750. <LI>.globl symbol
  751. <LI>.global symbol
  752. <LI>.section section
  753. <LI>.text
  754. <LI>.data
  755. <LI>.bss
  756. <LI>.fill repeat[,size[,value]]
  757. <LI>.org n
  758. <LI>.previous
  759. <LI>.string string[,...]
  760. <LI>.asciz string[,...]
  761. <LI>.ascii string[,...]
  762. </UL>
  763. <P>
  764. <HR SIZE="6">
  765. <A NAME="SEC15"></A>
  766. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  767. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC14"> &lt; </A>]</TD>
  768. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> &gt; </A>]</TD>
  769. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  770. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  771. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  772. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  773. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  774. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  775. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  776. </TR></TABLE>
  777. <H2> 4.5 X86 Assembler </H2>
  778. <!--docid::SEC15::-->
  779. <P>
  780. All X86 opcodes are supported. Only ATT syntax is supported (source
  781. then destination operand order). If no size suffix is given, TinyCC
  782. tries to guess it from the operand sizes.
  783. </P><P>
  784. Currently, MMX opcodes are supported but not SSE ones.
  785. </P><P>
  786. <HR SIZE="6">
  787. <A NAME="SEC16"></A>
  788. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  789. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC15"> &lt; </A>]</TD>
  790. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC17"> &gt; </A>]</TD>
  791. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  792. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  793. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  794. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  795. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  796. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  797. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  798. </TR></TABLE>
  799. <H1> 5. TinyCC Linker </H1>
  800. <!--docid::SEC16::-->
  801. <P>
  802. <HR SIZE="6">
  803. <A NAME="SEC17"></A>
  804. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  805. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC16"> &lt; </A>]</TD>
  806. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC18"> &gt; </A>]</TD>
  807. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  808. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  809. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  810. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  811. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  812. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  813. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  814. </TR></TABLE>
  815. <H2> 5.1 ELF file generation </H2>
  816. <!--docid::SEC17::-->
  817. <P>
  818. TCC can directly output relocatable ELF files (object files),
  819. executable ELF files and dynamic ELF libraries without relying on an
  820. external linker.
  821. </P><P>
  822. Dynamic ELF libraries can be output but the C compiler does not generate
  823. position independent code (PIC). It means that the dynamic library
  824. code generated by TCC cannot be factorized among processes yet.
  825. </P><P>
  826. TCC linker eliminates unreferenced object code in libraries. A single pass is
  827. done on the object and library list, so the order in which object files and
  828. libraries are specified is important (same constraint as GNU ld). No grouping
  829. options (<SAMP>`--start-group'</SAMP> and <SAMP>`--end-group'</SAMP>) are supported.
  830. </P><P>
  831. <HR SIZE="6">
  832. <A NAME="SEC18"></A>
  833. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  834. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC17"> &lt; </A>]</TD>
  835. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC19"> &gt; </A>]</TD>
  836. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  837. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  838. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  839. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  840. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  841. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  842. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  843. </TR></TABLE>
  844. <H2> 5.2 ELF file loader </H2>
  845. <!--docid::SEC18::-->
  846. <P>
  847. TCC can load ELF object files, archives (.a files) and dynamic
  848. libraries (.so).
  849. </P><P>
  850. <HR SIZE="6">
  851. <A NAME="SEC19"></A>
  852. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  853. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC18"> &lt; </A>]</TD>
  854. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC20"> &gt; </A>]</TD>
  855. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  856. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  857. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  858. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  859. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  860. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  861. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  862. </TR></TABLE>
  863. <H2> 5.3 PE-i386 file generation </H2>
  864. <!--docid::SEC19::-->
  865. <P>
  866. TCC for Windows supports the native Win32 executable file format (PE-i386). It
  867. generates both EXE and DLL files. DLL symbols can be imported thru DEF files
  868. generated with the <CODE>tiny_impdef</CODE> tool.
  869. </P><P>
  870. Currently TCC for Windows cannot generate nor read PE object files, so ELF
  871. object files are used for that purpose. It can be a problem if
  872. interoperability with MSVC is needed. Moreover, no leading underscore is
  873. currently generated in the ELF symbols.
  874. </P><P>
  875. <HR SIZE="6">
  876. <A NAME="SEC20"></A>
  877. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  878. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC19"> &lt; </A>]</TD>
  879. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> &gt; </A>]</TD>
  880. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  881. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  882. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  883. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  884. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  885. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  886. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  887. </TR></TABLE>
  888. <H2> 5.4 GNU Linker Scripts </H2>
  889. <!--docid::SEC20::-->
  890. <P>
  891. Because on many Linux systems some dynamic libraries (such as
  892. <TT>`/usr/lib/libc.so'</TT>) are in fact GNU ld link scripts (horrible!),
  893. the TCC linker also supports a subset of GNU ld scripts.
  894. </P><P>
  895. The <CODE>GROUP</CODE> and <CODE>FILE</CODE> commands are supported. <CODE>OUTPUT_FORMAT</CODE>
  896. and <CODE>TARGET</CODE> are ignored.
  897. </P><P>
  898. Example from <TT>`/usr/lib/libc.so'</TT>:
  899. <TABLE><tr><td>&nbsp;</td><td class=example><pre>/* GNU ld script
  900. Use the shared library, but some functions are only in
  901. the static library, so try that secondarily. */
  902. GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a )
  903. </pre></td></tr></table></P><P>
  904. <A NAME="Bounds"></A>
  905. <HR SIZE="6">
  906. <A NAME="SEC21"></A>
  907. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  908. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC20"> &lt; </A>]</TD>
  909. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC22"> &gt; </A>]</TD>
  910. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  911. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  912. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  913. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  914. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  915. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  916. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  917. </TR></TABLE>
  918. <H1> 6. TinyCC Memory and Bound checks </H1>
  919. <!--docid::SEC21::-->
  920. <P>
  921. This feature is activated with the <SAMP>`-b'</SAMP> (see section <A HREF="tcc-doc.html#SEC2">2. Command line invocation</A>).
  922. </P><P>
  923. Note that pointer size is <EM>unchanged</EM> and that code generated
  924. with bound checks is <EM>fully compatible</EM> with unchecked
  925. code. When a pointer comes from unchecked code, it is assumed to be
  926. valid. Even very obscure C code with casts should work correctly.
  927. </P><P>
  928. For more information about the ideas behind this method, see
  929. <A HREF="http://www.doc.ic.ac.uk/~phjk/BoundsChecking.html">http://www.doc.ic.ac.uk/~phjk/BoundsChecking.html</A>.
  930. </P><P>
  931. Here are some examples of caught errors:
  932. </P><P>
  933. <DL COMPACT>
  934. <DT>Invalid range with standard string function:
  935. <DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>{
  936. char tab[10];
  937. memset(tab, 0, 11);
  938. }
  939. </pre></td></tr></table><P>
  940. <DT>Out of bounds-error in global or local arrays:
  941. <DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>{
  942. int tab[10];
  943. for(i=0;i&#60;11;i++) {
  944. sum += tab[i];
  945. }
  946. }
  947. </pre></td></tr></table><P>
  948. <DT>Out of bounds-error in malloc'ed data:
  949. <DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>{
  950. int *tab;
  951. tab = malloc(20 * sizeof(int));
  952. for(i=0;i&#60;21;i++) {
  953. sum += tab4[i];
  954. }
  955. free(tab);
  956. }
  957. </pre></td></tr></table><P>
  958. <DT>Access of freed memory:
  959. <DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>{
  960. int *tab;
  961. tab = malloc(20 * sizeof(int));
  962. free(tab);
  963. for(i=0;i&#60;20;i++) {
  964. sum += tab4[i];
  965. }
  966. }
  967. </pre></td></tr></table><P>
  968. <DT>Double free:
  969. <DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>{
  970. int *tab;
  971. tab = malloc(20 * sizeof(int));
  972. free(tab);
  973. free(tab);
  974. }
  975. </pre></td></tr></table><P>
  976. </DL>
  977. <P>
  978. <A NAME="Libtcc"></A>
  979. <HR SIZE="6">
  980. <A NAME="SEC22"></A>
  981. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  982. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC21"> &lt; </A>]</TD>
  983. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> &gt; </A>]</TD>
  984. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  985. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  986. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  987. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  988. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  989. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  990. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  991. </TR></TABLE>
  992. <H1> 7. The <CODE>libtcc</CODE> library </H1>
  993. <!--docid::SEC22::-->
  994. <P>
  995. The <CODE>libtcc</CODE> library enables you to use TCC as a backend for
  996. dynamic code generation.
  997. </P><P>
  998. Read the <TT>`libtcc.h'</TT> to have an overview of the API. Read
  999. <TT>`libtcc_test.c'</TT> to have a very simple example.
  1000. </P><P>
  1001. The idea consists in giving a C string containing the program you want
  1002. to compile directly to <CODE>libtcc</CODE>. Then you can access to any global
  1003. symbol (function or variable) defined.
  1004. </P><P>
  1005. <HR SIZE="6">
  1006. <A NAME="SEC23"></A>
  1007. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1008. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC22"> &lt; </A>]</TD>
  1009. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC24"> &gt; </A>]</TD>
  1010. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  1011. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  1012. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  1013. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1014. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1015. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1016. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1017. </TR></TABLE>
  1018. <H1> 8. Developer's guide </H1>
  1019. <!--docid::SEC23::-->
  1020. <P>
  1021. This chapter gives some hints to understand how TCC works. You can skip
  1022. it if you do not intend to modify the TCC code.
  1023. </P><P>
  1024. <HR SIZE="6">
  1025. <A NAME="SEC24"></A>
  1026. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1027. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC23"> &lt; </A>]</TD>
  1028. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC25"> &gt; </A>]</TD>
  1029. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  1030. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  1031. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  1032. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1033. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1034. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1035. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1036. </TR></TABLE>
  1037. <H2> 8.1 File reading </H2>
  1038. <!--docid::SEC24::-->
  1039. <P>
  1040. The <CODE>BufferedFile</CODE> structure contains the context needed to read a
  1041. file, including the current line number. <CODE>tcc_open()</CODE> opens a new
  1042. file and <CODE>tcc_close()</CODE> closes it. <CODE>inp()</CODE> returns the next
  1043. character.
  1044. </P><P>
  1045. <HR SIZE="6">
  1046. <A NAME="SEC25"></A>
  1047. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1048. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC24"> &lt; </A>]</TD>
  1049. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC26"> &gt; </A>]</TD>
  1050. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  1051. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  1052. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  1053. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1054. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1055. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1056. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1057. </TR></TABLE>
  1058. <H2> 8.2 Lexer </H2>
  1059. <!--docid::SEC25::-->
  1060. <P>
  1061. <CODE>next()</CODE> reads the next token in the current
  1062. file. <CODE>next_nomacro()</CODE> reads the next token without macro
  1063. expansion.
  1064. </P><P>
  1065. <CODE>tok</CODE> contains the current token (see <CODE>TOK_xxx</CODE>)
  1066. constants. Identifiers and keywords are also keywords. <CODE>tokc</CODE>
  1067. contains additional infos about the token (for example a constant value
  1068. if number or string token).
  1069. </P><P>
  1070. <HR SIZE="6">
  1071. <A NAME="SEC26"></A>
  1072. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1073. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC25"> &lt; </A>]</TD>
  1074. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC27"> &gt; </A>]</TD>
  1075. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  1076. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  1077. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  1078. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1079. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1080. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1081. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1082. </TR></TABLE>
  1083. <H2> 8.3 Parser </H2>
  1084. <!--docid::SEC26::-->
  1085. <P>
  1086. The parser is hardcoded (yacc is not necessary). It does only one pass,
  1087. except:
  1088. </P><P>
  1089. <UL>
  1090. <LI>For initialized arrays with unknown size, a first pass
  1091. is done to count the number of elements.
  1092. <P>
  1093. <LI>For architectures where arguments are evaluated in
  1094. reverse order, a first pass is done to reverse the argument order.
  1095. <P>
  1096. </UL>
  1097. <P>
  1098. <HR SIZE="6">
  1099. <A NAME="SEC27"></A>
  1100. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1101. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC26"> &lt; </A>]</TD>
  1102. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC28"> &gt; </A>]</TD>
  1103. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  1104. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  1105. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  1106. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1107. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1108. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1109. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1110. </TR></TABLE>
  1111. <H2> 8.4 Types </H2>
  1112. <!--docid::SEC27::-->
  1113. <P>
  1114. The types are stored in a single 'int' variable. It was choosen in the
  1115. first stages of development when tcc was much simpler. Now, it may not
  1116. be the best solution.
  1117. </P><P>
  1118. <TABLE><tr><td>&nbsp;</td><td class=example><pre>#define VT_INT 0 /* integer type */
  1119. #define VT_BYTE 1 /* signed byte type */
  1120. #define VT_SHORT 2 /* short type */
  1121. #define VT_VOID 3 /* void type */
  1122. #define VT_PTR 4 /* pointer */
  1123. #define VT_ENUM 5 /* enum definition */
  1124. #define VT_FUNC 6 /* function type */
  1125. #define VT_STRUCT 7 /* struct/union definition */
  1126. #define VT_FLOAT 8 /* IEEE float */
  1127. #define VT_DOUBLE 9 /* IEEE double */
  1128. #define VT_LDOUBLE 10 /* IEEE long double */
  1129. #define VT_BOOL 11 /* ISOC99 boolean type */
  1130. #define VT_LLONG 12 /* 64 bit integer */
  1131. #define VT_LONG 13 /* long integer (NEVER USED as type, only
  1132. during parsing) */
  1133. #define VT_BTYPE 0x000f /* mask for basic type */
  1134. #define VT_UNSIGNED 0x0010 /* unsigned type */
  1135. #define VT_ARRAY 0x0020 /* array type (also has VT_PTR) */
  1136. #define VT_BITFIELD 0x0040 /* bitfield modifier */
  1137. #define VT_STRUCT_SHIFT 16 /* structure/enum name shift (16 bits left) */
  1138. </pre></td></tr></table></P><P>
  1139. When a reference to another type is needed (for pointers, functions and
  1140. structures), the <CODE>32 - VT_STRUCT_SHIFT</CODE> high order bits are used to
  1141. store an identifier reference.
  1142. </P><P>
  1143. The <CODE>VT_UNSIGNED</CODE> flag can be set for chars, shorts, ints and long
  1144. longs.
  1145. </P><P>
  1146. Arrays are considered as pointers <CODE>VT_PTR</CODE> with the flag
  1147. <CODE>VT_ARRAY</CODE> set.
  1148. </P><P>
  1149. The <CODE>VT_BITFIELD</CODE> flag can be set for chars, shorts, ints and long
  1150. longs. If it is set, then the bitfield position is stored from bits
  1151. VT_STRUCT_SHIFT to VT_STRUCT_SHIFT + 5 and the bit field size is stored
  1152. from bits VT_STRUCT_SHIFT + 6 to VT_STRUCT_SHIFT + 11.
  1153. </P><P>
  1154. <CODE>VT_LONG</CODE> is never used except during parsing.
  1155. </P><P>
  1156. During parsing, the storage of an object is also stored in the type
  1157. integer:
  1158. </P><P>
  1159. <TABLE><tr><td>&nbsp;</td><td class=example><pre>#define VT_EXTERN 0x00000080 /* extern definition */
  1160. #define VT_STATIC 0x00000100 /* static variable */
  1161. #define VT_TYPEDEF 0x00000200 /* typedef definition */
  1162. </pre></td></tr></table></P><P>
  1163. <HR SIZE="6">
  1164. <A NAME="SEC28"></A>
  1165. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1166. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC27"> &lt; </A>]</TD>
  1167. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC29"> &gt; </A>]</TD>
  1168. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  1169. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  1170. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  1171. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1172. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1173. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1174. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1175. </TR></TABLE>
  1176. <H2> 8.5 Symbols </H2>
  1177. <!--docid::SEC28::-->
  1178. <P>
  1179. All symbols are stored in hashed symbol stacks. Each symbol stack
  1180. contains <CODE>Sym</CODE> structures.
  1181. </P><P>
  1182. <CODE>Sym.v</CODE> contains the symbol name (remember
  1183. an idenfier is also a token, so a string is never necessary to store
  1184. it). <CODE>Sym.t</CODE> gives the type of the symbol. <CODE>Sym.r</CODE> is usually
  1185. the register in which the corresponding variable is stored. <CODE>Sym.c</CODE> is
  1186. usually a constant associated to the symbol.
  1187. </P><P>
  1188. Four main symbol stacks are defined:
  1189. </P><P>
  1190. <DL COMPACT>
  1191. <DT><CODE>define_stack</CODE>
  1192. <DD>for the macros (<CODE>#define</CODE>s).
  1193. <P>
  1194. <DT><CODE>global_stack</CODE>
  1195. <DD>for the global variables, functions and types.
  1196. <P>
  1197. <DT><CODE>local_stack</CODE>
  1198. <DD>for the local variables, functions and types.
  1199. <P>
  1200. <DT><CODE>global_label_stack</CODE>
  1201. <DD>for the local labels (for <CODE>goto</CODE>).
  1202. <P>
  1203. <DT><CODE>label_stack</CODE>
  1204. <DD>for GCC block local labels (see the <CODE>__label__</CODE> keyword).
  1205. <P>
  1206. </DL>
  1207. <P>
  1208. <CODE>sym_push()</CODE> is used to add a new symbol in the local symbol
  1209. stack. If no local symbol stack is active, it is added in the global
  1210. symbol stack.
  1211. </P><P>
  1212. <CODE>sym_pop(st,b)</CODE> pops symbols from the symbol stack <VAR>st</VAR> until
  1213. the symbol <VAR>b</VAR> is on the top of stack. If <VAR>b</VAR> is NULL, the stack
  1214. is emptied.
  1215. </P><P>
  1216. <CODE>sym_find(v)</CODE> return the symbol associated to the identifier
  1217. <VAR>v</VAR>. The local stack is searched first from top to bottom, then the
  1218. global stack.
  1219. </P><P>
  1220. <HR SIZE="6">
  1221. <A NAME="SEC29"></A>
  1222. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1223. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC28"> &lt; </A>]</TD>
  1224. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> &gt; </A>]</TD>
  1225. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  1226. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  1227. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  1228. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1229. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1230. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1231. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1232. </TR></TABLE>
  1233. <H2> 8.6 Sections </H2>
  1234. <!--docid::SEC29::-->
  1235. <P>
  1236. The generated code and datas are written in sections. The structure
  1237. <CODE>Section</CODE> contains all the necessary information for a given
  1238. section. <CODE>new_section()</CODE> creates a new section. ELF file semantics
  1239. is assumed for each section.
  1240. </P><P>
  1241. The following sections are predefined:
  1242. </P><P>
  1243. <DL COMPACT>
  1244. <DT><CODE>text_section</CODE>
  1245. <DD>is the section containing the generated code. <VAR>ind</VAR> contains the
  1246. current position in the code section.
  1247. <P>
  1248. <DT><CODE>data_section</CODE>
  1249. <DD>contains initialized data
  1250. <P>
  1251. <DT><CODE>bss_section</CODE>
  1252. <DD>contains uninitialized data
  1253. <P>
  1254. <DT><CODE>bounds_section</CODE>
  1255. <DD><DT><CODE>lbounds_section</CODE>
  1256. <DD>are used when bound checking is activated
  1257. <P>
  1258. <DT><CODE>stab_section</CODE>
  1259. <DD><DT><CODE>stabstr_section</CODE>
  1260. <DD>are used when debugging is actived to store debug information
  1261. <P>
  1262. <DT><CODE>symtab_section</CODE>
  1263. <DD><DT><CODE>strtab_section</CODE>
  1264. <DD>contain the exported symbols (currently only used for debugging).
  1265. <P>
  1266. </DL>
  1267. <P>
  1268. <HR SIZE="6">
  1269. <A NAME="SEC30"></A>
  1270. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1271. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC29"> &lt; </A>]</TD>
  1272. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC31"> &gt; </A>]</TD>
  1273. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  1274. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  1275. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  1276. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1277. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1278. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1279. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1280. </TR></TABLE>
  1281. <H2> 8.7 Code generation </H2>
  1282. <!--docid::SEC30::-->
  1283. <P>
  1284. <HR SIZE="6">
  1285. <A NAME="SEC31"></A>
  1286. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1287. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> &lt; </A>]</TD>
  1288. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC32"> &gt; </A>]</TD>
  1289. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  1290. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  1291. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  1292. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1293. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1294. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1295. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1296. </TR></TABLE>
  1297. <H3> 8.7.1 Introduction </H3>
  1298. <!--docid::SEC31::-->
  1299. <P>
  1300. The TCC code generator directly generates linked binary code in one
  1301. pass. It is rather unusual these days (see gcc for example which
  1302. generates text assembly), but it can be very fast and surprisingly
  1303. little complicated.
  1304. </P><P>
  1305. The TCC code generator is register based. Optimization is only done at
  1306. the expression level. No intermediate representation of expression is
  1307. kept except the current values stored in the <EM>value stack</EM>.
  1308. </P><P>
  1309. On x86, three temporary registers are used. When more registers are
  1310. needed, one register is spilled into a new temporary variable on the stack.
  1311. </P><P>
  1312. <HR SIZE="6">
  1313. <A NAME="SEC32"></A>
  1314. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1315. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC31"> &lt; </A>]</TD>
  1316. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC33"> &gt; </A>]</TD>
  1317. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  1318. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  1319. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  1320. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1321. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1322. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1323. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1324. </TR></TABLE>
  1325. <H3> 8.7.2 The value stack </H3>
  1326. <!--docid::SEC32::-->
  1327. <P>
  1328. When an expression is parsed, its value is pushed on the value stack
  1329. (<VAR>vstack</VAR>). The top of the value stack is <VAR>vtop</VAR>. Each value
  1330. stack entry is the structure <CODE>SValue</CODE>.
  1331. </P><P>
  1332. <CODE>SValue.t</CODE> is the type. <CODE>SValue.r</CODE> indicates how the value is
  1333. currently stored in the generated code. It is usually a CPU register
  1334. index (<CODE>REG_xxx</CODE> constants), but additional values and flags are
  1335. defined:
  1336. </P><P>
  1337. <TABLE><tr><td>&nbsp;</td><td class=example><pre>#define VT_CONST 0x00f0
  1338. #define VT_LLOCAL 0x00f1
  1339. #define VT_LOCAL 0x00f2
  1340. #define VT_CMP 0x00f3
  1341. #define VT_JMP 0x00f4
  1342. #define VT_JMPI 0x00f5
  1343. #define VT_LVAL 0x0100
  1344. #define VT_SYM 0x0200
  1345. #define VT_MUSTCAST 0x0400
  1346. #define VT_MUSTBOUND 0x0800
  1347. #define VT_BOUNDED 0x8000
  1348. #define VT_LVAL_BYTE 0x1000
  1349. #define VT_LVAL_SHORT 0x2000
  1350. #define VT_LVAL_UNSIGNED 0x4000
  1351. #define VT_LVAL_TYPE (VT_LVAL_BYTE | VT_LVAL_SHORT | VT_LVAL_UNSIGNED)
  1352. </pre></td></tr></table></P><P>
  1353. <DL COMPACT>
  1354. <DT><CODE>VT_CONST</CODE>
  1355. <DD>indicates that the value is a constant. It is stored in the union
  1356. <CODE>SValue.c</CODE>, depending on its type.
  1357. <P>
  1358. <DT><CODE>VT_LOCAL</CODE>
  1359. <DD>indicates a local variable pointer at offset <CODE>SValue.c.i</CODE> in the
  1360. stack.
  1361. <P>
  1362. <DT><CODE>VT_CMP</CODE>
  1363. <DD>indicates that the value is actually stored in the CPU flags (i.e. the
  1364. value is the consequence of a test). The value is either 0 or 1. The
  1365. actual CPU flags used is indicated in <CODE>SValue.c.i</CODE>.
  1366. <P>
  1367. If any code is generated which destroys the CPU flags, this value MUST be
  1368. put in a normal register.
  1369. </P><P>
  1370. <DT><CODE>VT_JMP</CODE>
  1371. <DD><DT><CODE>VT_JMPI</CODE>
  1372. <DD>indicates that the value is the consequence of a conditional jump. For VT_JMP,
  1373. it is 1 if the jump is taken, 0 otherwise. For VT_JMPI it is inverted.
  1374. <P>
  1375. These values are used to compile the <CODE>||</CODE> and <CODE>&#38;&#38;</CODE> logical
  1376. operators.
  1377. </P><P>
  1378. If any code is generated, this value MUST be put in a normal
  1379. register. Otherwise, the generated code won't be executed if the jump is
  1380. taken.
  1381. </P><P>
  1382. <DT><CODE>VT_LVAL</CODE>
  1383. <DD>is a flag indicating that the value is actually an lvalue (left value of
  1384. an assignment). It means that the value stored is actually a pointer to
  1385. the wanted value.
  1386. <P>
  1387. Understanding the use <CODE>VT_LVAL</CODE> is very important if you want to
  1388. understand how TCC works.
  1389. </P><P>
  1390. <DT><CODE>VT_LVAL_BYTE</CODE>
  1391. <DD><DT><CODE>VT_LVAL_SHORT</CODE>
  1392. <DD><DT><CODE>VT_LVAL_UNSIGNED</CODE>
  1393. <DD>if the lvalue has an integer type, then these flags give its real
  1394. type. The type alone is not enough in case of cast optimisations.
  1395. <P>
  1396. <DT><CODE>VT_LLOCAL</CODE>
  1397. <DD>is a saved lvalue on the stack. <CODE>VT_LLOCAL</CODE> should be eliminated
  1398. ASAP because its semantics are rather complicated.
  1399. <P>
  1400. <DT><CODE>VT_MUSTCAST</CODE>
  1401. <DD>indicates that a cast to the value type must be performed if the value
  1402. is used (lazy casting).
  1403. <P>
  1404. <DT><CODE>VT_SYM</CODE>
  1405. <DD>indicates that the symbol <CODE>SValue.sym</CODE> must be added to the constant.
  1406. <P>
  1407. <DT><CODE>VT_MUSTBOUND</CODE>
  1408. <DD><DT><CODE>VT_BOUNDED</CODE>
  1409. <DD>are only used for optional bound checking.
  1410. <P>
  1411. </DL>
  1412. <P>
  1413. <HR SIZE="6">
  1414. <A NAME="SEC33"></A>
  1415. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1416. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC32"> &lt; </A>]</TD>
  1417. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC34"> &gt; </A>]</TD>
  1418. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  1419. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  1420. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  1421. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1422. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1423. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1424. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1425. </TR></TABLE>
  1426. <H3> 8.7.3 Manipulating the value stack </H3>
  1427. <!--docid::SEC33::-->
  1428. <P>
  1429. <CODE>vsetc()</CODE> and <CODE>vset()</CODE> pushes a new value on the value
  1430. stack. If the previous <VAR>vtop</VAR> was stored in a very unsafe place(for
  1431. example in the CPU flags), then some code is generated to put the
  1432. previous <VAR>vtop</VAR> in a safe storage.
  1433. </P><P>
  1434. <CODE>vpop()</CODE> pops <VAR>vtop</VAR>. In some cases, it also generates cleanup
  1435. code (for example if stacked floating point registers are used as on
  1436. x86).
  1437. </P><P>
  1438. The <CODE>gv(rc)</CODE> function generates code to evaluate <VAR>vtop</VAR> (the
  1439. top value of the stack) into registers. <VAR>rc</VAR> selects in which
  1440. register class the value should be put. <CODE>gv()</CODE> is the <EM>most
  1441. important function</EM> of the code generator.
  1442. </P><P>
  1443. <CODE>gv2()</CODE> is the same as <CODE>gv()</CODE> but for the top two stack
  1444. entries.
  1445. </P><P>
  1446. <HR SIZE="6">
  1447. <A NAME="SEC34"></A>
  1448. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1449. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC33"> &lt; </A>]</TD>
  1450. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> &gt; </A>]</TD>
  1451. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  1452. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  1453. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  1454. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1455. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1456. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1457. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1458. </TR></TABLE>
  1459. <H3> 8.7.4 CPU dependent code generation </H3>
  1460. <!--docid::SEC34::-->
  1461. See the <TT>`i386-gen.c'</TT> file to have an example.
  1462. <P>
  1463. <DL COMPACT>
  1464. <DT><CODE>load()</CODE>
  1465. <DD>must generate the code needed to load a stack value into a register.
  1466. <P>
  1467. <DT><CODE>store()</CODE>
  1468. <DD>must generate the code needed to store a register into a stack value
  1469. lvalue.
  1470. <P>
  1471. <DT><CODE>gfunc_start()</CODE>
  1472. <DD><DT><CODE>gfunc_param()</CODE>
  1473. <DD><DT><CODE>gfunc_call()</CODE>
  1474. <DD>should generate a function call
  1475. <P>
  1476. <DT><CODE>gfunc_prolog()</CODE>
  1477. <DD><DT><CODE>gfunc_epilog()</CODE>
  1478. <DD>should generate a function prolog/epilog.
  1479. <P>
  1480. <DT><CODE>gen_opi(op)</CODE>
  1481. <DD>must generate the binary integer operation <VAR>op</VAR> on the two top
  1482. entries of the stack which are guaranted to contain integer types.
  1483. <P>
  1484. The result value should be put on the stack.
  1485. </P><P>
  1486. <DT><CODE>gen_opf(op)</CODE>
  1487. <DD>same as <CODE>gen_opi()</CODE> for floating point operations. The two top
  1488. entries of the stack are guaranted to contain floating point values of
  1489. same types.
  1490. <P>
  1491. <DT><CODE>gen_cvt_itof()</CODE>
  1492. <DD>integer to floating point conversion.
  1493. <P>
  1494. <DT><CODE>gen_cvt_ftoi()</CODE>
  1495. <DD>floating point to integer conversion.
  1496. <P>
  1497. <DT><CODE>gen_cvt_ftof()</CODE>
  1498. <DD>floating point to floating point of different size conversion.
  1499. <P>
  1500. <DT><CODE>gen_bounded_ptr_add()</CODE>
  1501. <DD><DT><CODE>gen_bounded_ptr_deref()</CODE>
  1502. <DD>are only used for bounds checking.
  1503. <P>
  1504. </DL>
  1505. <P>
  1506. <HR SIZE="6">
  1507. <A NAME="SEC35"></A>
  1508. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1509. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC34"> &lt; </A>]</TD>
  1510. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36"> &gt; </A>]</TD>
  1511. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  1512. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  1513. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  1514. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1515. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1516. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1517. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1518. </TR></TABLE>
  1519. <H2> 8.8 Optimizations done </H2>
  1520. <!--docid::SEC35::-->
  1521. Constant propagation is done for all operations. Multiplications and
  1522. divisions are optimized to shifts when appropriate. Comparison
  1523. operators are optimized by maintaining a special cache for the
  1524. processor flags. &#38;&#38;, || and ! are optimized by maintaining a special
  1525. 'jump target' value. No other jump optimization is currently performed
  1526. because it would require to store the code in a more abstract fashion.
  1527. <P>
  1528. <HR SIZE="6">
  1529. <A NAME="SEC36"></A>
  1530. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1531. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC35"> &lt; </A>]</TD>
  1532. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt; ]</TD>
  1533. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD>
  1534. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD>
  1535. <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD>
  1536. <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1537. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1538. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1539. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1540. </TR></TABLE>
  1541. <H1> Concept Index </H1>
  1542. <!--docid::SEC36::-->
  1543. <table><tr><th valign=top>Jump to: &nbsp; </th><td><A HREF="tcc-doc.html#cp__" style="text-decoration:none"><b>_</b></A>
  1544. &nbsp;
  1545. <BR>
  1546. <A HREF="tcc-doc.html#cp_A" style="text-decoration:none"><b>A</b></A>
  1547. &nbsp;
  1548. <A HREF="tcc-doc.html#cp_B" style="text-decoration:none"><b>B</b></A>
  1549. &nbsp;
  1550. <A HREF="tcc-doc.html#cp_C" style="text-decoration:none"><b>C</b></A>
  1551. &nbsp;
  1552. <A HREF="tcc-doc.html#cp_D" style="text-decoration:none"><b>D</b></A>
  1553. &nbsp;
  1554. <A HREF="tcc-doc.html#cp_E" style="text-decoration:none"><b>E</b></A>
  1555. &nbsp;
  1556. <A HREF="tcc-doc.html#cp_F" style="text-decoration:none"><b>F</b></A>
  1557. &nbsp;
  1558. <A HREF="tcc-doc.html#cp_G" style="text-decoration:none"><b>G</b></A>
  1559. &nbsp;
  1560. <A HREF="tcc-doc.html#cp_I" style="text-decoration:none"><b>I</b></A>
  1561. &nbsp;
  1562. <A HREF="tcc-doc.html#cp_J" style="text-decoration:none"><b>J</b></A>
  1563. &nbsp;
  1564. <A HREF="tcc-doc.html#cp_L" style="text-decoration:none"><b>L</b></A>
  1565. &nbsp;
  1566. <A HREF="tcc-doc.html#cp_M" style="text-decoration:none"><b>M</b></A>
  1567. &nbsp;
  1568. <A HREF="tcc-doc.html#cp_O" style="text-decoration:none"><b>O</b></A>
  1569. &nbsp;
  1570. <A HREF="tcc-doc.html#cp_P" style="text-decoration:none"><b>P</b></A>
  1571. &nbsp;
  1572. <A HREF="tcc-doc.html#cp_Q" style="text-decoration:none"><b>Q</b></A>
  1573. &nbsp;
  1574. <A HREF="tcc-doc.html#cp_R" style="text-decoration:none"><b>R</b></A>
  1575. &nbsp;
  1576. <A HREF="tcc-doc.html#cp_S" style="text-decoration:none"><b>S</b></A>
  1577. &nbsp;
  1578. <A HREF="tcc-doc.html#cp_T" style="text-decoration:none"><b>T</b></A>
  1579. &nbsp;
  1580. <A HREF="tcc-doc.html#cp_U" style="text-decoration:none"><b>U</b></A>
  1581. &nbsp;
  1582. <A HREF="tcc-doc.html#cp_V" style="text-decoration:none"><b>V</b></A>
  1583. &nbsp;
  1584. <A HREF="tcc-doc.html#cp_W" style="text-decoration:none"><b>W</b></A>
  1585. &nbsp;
  1586. </td></tr></table><br><P></P>
  1587. <TABLE border=0>
  1588. <TR><TD></TD><TH ALIGN=LEFT>Index Entry</TH><TH ALIGN=LEFT> Section</TH></TR>
  1589. <TR><TD COLSPAN=3> <HR></TD></TR>
  1590. <TR><TH><A NAME="cp__"></A>_</TH><TD></TD><TD></TD></TR>
  1591. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX3">__asm__</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
  1592. <TR><TD COLSPAN=3> <HR></TD></TR>
  1593. <TR><TH><A NAME="cp_A"></A>A</TH><TD></TD><TD></TD></TR>
  1594. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">align directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1595. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">aligned attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
  1596. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">ascii directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1597. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">asciz directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1598. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC15">assembler</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC15">4.5 X86 Assembler</A></TD></TR>
  1599. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">assembler directives</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1600. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX2">assembly, inline</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
  1601. <TR><TD COLSPAN=3> <HR></TD></TR>
  1602. <TR><TH><A NAME="cp_B"></A>B</TH><TD></TD><TD></TD></TR>
  1603. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC21">bound checks</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A></TD></TR>
  1604. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">bss directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1605. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">byte directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1606. <TR><TD COLSPAN=3> <HR></TD></TR>
  1607. <TR><TH><A NAME="cp_C"></A>C</TH><TD></TD><TD></TD></TR>
  1608. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">caching processor flags</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
  1609. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">cdecl attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
  1610. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC30">code generation</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC30">8.7 Code generation</A></TD></TR>
  1611. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">comparison operators</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
  1612. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">constant propagation</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
  1613. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC34">CPU dependent</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC34">8.7.4 CPU dependent code generation</A></TD></TR>
  1614. <TR><TD COLSPAN=3> <HR></TD></TR>
  1615. <TR><TH><A NAME="cp_D"></A>D</TH><TD></TD><TD></TD></TR>
  1616. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">data directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1617. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">directives, assembler</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1618. <TR><TD COLSPAN=3> <HR></TD></TR>
  1619. <TR><TH><A NAME="cp_E"></A>E</TH><TD></TD><TD></TD></TR>
  1620. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC17">ELF</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC17">5.1 ELF file generation</A></TD></TR>
  1621. <TR><TD COLSPAN=3> <HR></TD></TR>
  1622. <TR><TH><A NAME="cp_F"></A>F</TH><TD></TD><TD></TD></TR>
  1623. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">FILE, linker command</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
  1624. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">fill directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1625. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">flags, caching</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
  1626. <TR><TD COLSPAN=3> <HR></TD></TR>
  1627. <TR><TH><A NAME="cp_G"></A>G</TH><TD></TD><TD></TD></TR>
  1628. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX4">gas</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
  1629. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">global directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1630. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">globl directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1631. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">GROUP, linker command</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
  1632. <TR><TD COLSPAN=3> <HR></TD></TR>
  1633. <TR><TH><A NAME="cp_I"></A>I</TH><TD></TD><TD></TD></TR>
  1634. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#IDX1">inline assembly</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
  1635. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">int directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1636. <TR><TD COLSPAN=3> <HR></TD></TR>
  1637. <TR><TH><A NAME="cp_J"></A>J</TH><TD></TD><TD></TD></TR>
  1638. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">jump optimization</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
  1639. <TR><TD COLSPAN=3> <HR></TD></TR>
  1640. <TR><TH><A NAME="cp_L"></A>L</TH><TD></TD><TD></TD></TR>
  1641. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC16">linker</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC16">5. TinyCC Linker</A></TD></TR>
  1642. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">linker scripts</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
  1643. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">long directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1644. <TR><TD COLSPAN=3> <HR></TD></TR>
  1645. <TR><TH><A NAME="cp_M"></A>M</TH><TD></TD><TD></TD></TR>
  1646. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC21">memory checks</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A></TD></TR>
  1647. <TR><TD COLSPAN=3> <HR></TD></TR>
  1648. <TR><TH><A NAME="cp_O"></A>O</TH><TD></TD><TD></TD></TR>
  1649. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">optimizations</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
  1650. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">org directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1651. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">OUTPUT_FORMAT, linker command</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
  1652. <TR><TD COLSPAN=3> <HR></TD></TR>
  1653. <TR><TH><A NAME="cp_P"></A>P</TH><TD></TD><TD></TD></TR>
  1654. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">packed attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
  1655. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC19">PE-i386</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC19">5.3 PE-i386 file generation</A></TD></TR>
  1656. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">previous directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1657. <TR><TD COLSPAN=3> <HR></TD></TR>
  1658. <TR><TH><A NAME="cp_Q"></A>Q</TH><TD></TD><TD></TD></TR>
  1659. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">quad directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1660. <TR><TD COLSPAN=3> <HR></TD></TR>
  1661. <TR><TH><A NAME="cp_R"></A>R</TH><TD></TD><TD></TD></TR>
  1662. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">regparm attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
  1663. <TR><TD COLSPAN=3> <HR></TD></TR>
  1664. <TR><TH><A NAME="cp_S"></A>S</TH><TD></TD><TD></TD></TR>
  1665. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">scripts, linker</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
  1666. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">section attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
  1667. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">section directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1668. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">short directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1669. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">skip directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1670. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">space directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1671. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">stdcall attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
  1672. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">strength reduction</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A></TD></TR>
  1673. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">string directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1674. <TR><TD COLSPAN=3> <HR></TD></TR>
  1675. <TR><TH><A NAME="cp_T"></A>T</TH><TD></TD><TD></TD></TR>
  1676. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">TARGET, linker command</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A></TD></TR>
  1677. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">text directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1678. <TR><TD COLSPAN=3> <HR></TD></TR>
  1679. <TR><TH><A NAME="cp_U"></A>U</TH><TD></TD><TD></TD></TR>
  1680. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">unused attribute</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A></TD></TR>
  1681. <TR><TD COLSPAN=3> <HR></TD></TR>
  1682. <TR><TH><A NAME="cp_V"></A>V</TH><TD></TD><TD></TD></TR>
  1683. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC33">value stack</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC33">8.7.3 Manipulating the value stack</A></TD></TR>
  1684. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC32">value stack, introduction</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC32">8.7.2 The value stack</A></TD></TR>
  1685. <TR><TD COLSPAN=3> <HR></TD></TR>
  1686. <TR><TH><A NAME="cp_W"></A>W</TH><TD></TD><TD></TD></TR>
  1687. <TR><TD></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">word directive</A></TD><TD valign=top><A HREF="tcc-doc.html#SEC14">4.4 Directives</A></TD></TR>
  1688. <TR><TD COLSPAN=3> <HR></TD></TR>
  1689. </TABLE><P></P><table><tr><th valign=top>Jump to: &nbsp; </th><td><A HREF="tcc-doc.html#cp__" style="text-decoration:none"><b>_</b></A>
  1690. &nbsp;
  1691. <BR>
  1692. <A HREF="tcc-doc.html#cp_A" style="text-decoration:none"><b>A</b></A>
  1693. &nbsp;
  1694. <A HREF="tcc-doc.html#cp_B" style="text-decoration:none"><b>B</b></A>
  1695. &nbsp;
  1696. <A HREF="tcc-doc.html#cp_C" style="text-decoration:none"><b>C</b></A>
  1697. &nbsp;
  1698. <A HREF="tcc-doc.html#cp_D" style="text-decoration:none"><b>D</b></A>
  1699. &nbsp;
  1700. <A HREF="tcc-doc.html#cp_E" style="text-decoration:none"><b>E</b></A>
  1701. &nbsp;
  1702. <A HREF="tcc-doc.html#cp_F" style="text-decoration:none"><b>F</b></A>
  1703. &nbsp;
  1704. <A HREF="tcc-doc.html#cp_G" style="text-decoration:none"><b>G</b></A>
  1705. &nbsp;
  1706. <A HREF="tcc-doc.html#cp_I" style="text-decoration:none"><b>I</b></A>
  1707. &nbsp;
  1708. <A HREF="tcc-doc.html#cp_J" style="text-decoration:none"><b>J</b></A>
  1709. &nbsp;
  1710. <A HREF="tcc-doc.html#cp_L" style="text-decoration:none"><b>L</b></A>
  1711. &nbsp;
  1712. <A HREF="tcc-doc.html#cp_M" style="text-decoration:none"><b>M</b></A>
  1713. &nbsp;
  1714. <A HREF="tcc-doc.html#cp_O" style="text-decoration:none"><b>O</b></A>
  1715. &nbsp;
  1716. <A HREF="tcc-doc.html#cp_P" style="text-decoration:none"><b>P</b></A>
  1717. &nbsp;
  1718. <A HREF="tcc-doc.html#cp_Q" style="text-decoration:none"><b>Q</b></A>
  1719. &nbsp;
  1720. <A HREF="tcc-doc.html#cp_R" style="text-decoration:none"><b>R</b></A>
  1721. &nbsp;
  1722. <A HREF="tcc-doc.html#cp_S" style="text-decoration:none"><b>S</b></A>
  1723. &nbsp;
  1724. <A HREF="tcc-doc.html#cp_T" style="text-decoration:none"><b>T</b></A>
  1725. &nbsp;
  1726. <A HREF="tcc-doc.html#cp_U" style="text-decoration:none"><b>U</b></A>
  1727. &nbsp;
  1728. <A HREF="tcc-doc.html#cp_V" style="text-decoration:none"><b>V</b></A>
  1729. &nbsp;
  1730. <A HREF="tcc-doc.html#cp_W" style="text-decoration:none"><b>W</b></A>
  1731. &nbsp;
  1732. </td></tr></table><br><P>
  1733. <HR SIZE="6">
  1734. <A NAME="SEC_Contents"></A>
  1735. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1736. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1737. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1738. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1739. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1740. </TR></TABLE>
  1741. <H1>Table of Contents</H1>
  1742. <UL>
  1743. <A NAME="TOC1" HREF="tcc-doc.html#SEC1">1. Introduction</A>
  1744. <BR>
  1745. <A NAME="TOC2" HREF="tcc-doc.html#SEC2">2. Command line invocation</A>
  1746. <BR>
  1747. <UL>
  1748. <A NAME="TOC3" HREF="tcc-doc.html#SEC3">2.1 Quick start</A>
  1749. <BR>
  1750. <A NAME="TOC4" HREF="tcc-doc.html#SEC4">2.2 Option summary</A>
  1751. <BR>
  1752. </UL>
  1753. <A NAME="TOC5" HREF="tcc-doc.html#SEC5">3. C language support</A>
  1754. <BR>
  1755. <UL>
  1756. <A NAME="TOC6" HREF="tcc-doc.html#SEC6">3.1 ANSI C</A>
  1757. <BR>
  1758. <A NAME="TOC7" HREF="tcc-doc.html#SEC7">3.2 ISOC99 extensions</A>
  1759. <BR>
  1760. <A NAME="TOC8" HREF="tcc-doc.html#SEC8">3.3 GNU C extensions</A>
  1761. <BR>
  1762. <A NAME="TOC9" HREF="tcc-doc.html#SEC9">3.4 TinyCC extensions</A>
  1763. <BR>
  1764. </UL>
  1765. <A NAME="TOC10" HREF="tcc-doc.html#SEC10">4. TinyCC Assembler</A>
  1766. <BR>
  1767. <UL>
  1768. <A NAME="TOC11" HREF="tcc-doc.html#SEC11">4.1 Syntax</A>
  1769. <BR>
  1770. <A NAME="TOC12" HREF="tcc-doc.html#SEC12">4.2 Expressions</A>
  1771. <BR>
  1772. <A NAME="TOC13" HREF="tcc-doc.html#SEC13">4.3 Labels</A>
  1773. <BR>
  1774. <A NAME="TOC14" HREF="tcc-doc.html#SEC14">4.4 Directives</A>
  1775. <BR>
  1776. <A NAME="TOC15" HREF="tcc-doc.html#SEC15">4.5 X86 Assembler</A>
  1777. <BR>
  1778. </UL>
  1779. <A NAME="TOC16" HREF="tcc-doc.html#SEC16">5. TinyCC Linker</A>
  1780. <BR>
  1781. <UL>
  1782. <A NAME="TOC17" HREF="tcc-doc.html#SEC17">5.1 ELF file generation</A>
  1783. <BR>
  1784. <A NAME="TOC18" HREF="tcc-doc.html#SEC18">5.2 ELF file loader</A>
  1785. <BR>
  1786. <A NAME="TOC19" HREF="tcc-doc.html#SEC19">5.3 PE-i386 file generation</A>
  1787. <BR>
  1788. <A NAME="TOC20" HREF="tcc-doc.html#SEC20">5.4 GNU Linker Scripts</A>
  1789. <BR>
  1790. </UL>
  1791. <A NAME="TOC21" HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A>
  1792. <BR>
  1793. <A NAME="TOC22" HREF="tcc-doc.html#SEC22">7. The <CODE>libtcc</CODE> library</A>
  1794. <BR>
  1795. <A NAME="TOC23" HREF="tcc-doc.html#SEC23">8. Developer's guide</A>
  1796. <BR>
  1797. <UL>
  1798. <A NAME="TOC24" HREF="tcc-doc.html#SEC24">8.1 File reading</A>
  1799. <BR>
  1800. <A NAME="TOC25" HREF="tcc-doc.html#SEC25">8.2 Lexer</A>
  1801. <BR>
  1802. <A NAME="TOC26" HREF="tcc-doc.html#SEC26">8.3 Parser</A>
  1803. <BR>
  1804. <A NAME="TOC27" HREF="tcc-doc.html#SEC27">8.4 Types</A>
  1805. <BR>
  1806. <A NAME="TOC28" HREF="tcc-doc.html#SEC28">8.5 Symbols</A>
  1807. <BR>
  1808. <A NAME="TOC29" HREF="tcc-doc.html#SEC29">8.6 Sections</A>
  1809. <BR>
  1810. <A NAME="TOC30" HREF="tcc-doc.html#SEC30">8.7 Code generation</A>
  1811. <BR>
  1812. <UL>
  1813. <A NAME="TOC31" HREF="tcc-doc.html#SEC31">8.7.1 Introduction</A>
  1814. <BR>
  1815. <A NAME="TOC32" HREF="tcc-doc.html#SEC32">8.7.2 The value stack</A>
  1816. <BR>
  1817. <A NAME="TOC33" HREF="tcc-doc.html#SEC33">8.7.3 Manipulating the value stack</A>
  1818. <BR>
  1819. <A NAME="TOC34" HREF="tcc-doc.html#SEC34">8.7.4 CPU dependent code generation</A>
  1820. <BR>
  1821. </UL>
  1822. <A NAME="TOC35" HREF="tcc-doc.html#SEC35">8.8 Optimizations done</A>
  1823. <BR>
  1824. </UL>
  1825. <A NAME="TOC36" HREF="tcc-doc.html#SEC36">Concept Index</A>
  1826. <BR>
  1827. </UL>
  1828. <HR SIZE=1>
  1829. <A NAME="SEC_OVERVIEW"></A>
  1830. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1831. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1832. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1833. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1834. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1835. </TR></TABLE>
  1836. <H1>Short Table of Contents</H1>
  1837. <BLOCKQUOTE>
  1838. <A NAME="TOC1" HREF="tcc-doc.html#SEC1">1. Introduction</A>
  1839. <BR>
  1840. <A NAME="TOC2" HREF="tcc-doc.html#SEC2">2. Command line invocation</A>
  1841. <BR>
  1842. <A NAME="TOC5" HREF="tcc-doc.html#SEC5">3. C language support</A>
  1843. <BR>
  1844. <A NAME="TOC10" HREF="tcc-doc.html#SEC10">4. TinyCC Assembler</A>
  1845. <BR>
  1846. <A NAME="TOC16" HREF="tcc-doc.html#SEC16">5. TinyCC Linker</A>
  1847. <BR>
  1848. <A NAME="TOC21" HREF="tcc-doc.html#SEC21">6. TinyCC Memory and Bound checks</A>
  1849. <BR>
  1850. <A NAME="TOC22" HREF="tcc-doc.html#SEC22">7. The <CODE>libtcc</CODE> library</A>
  1851. <BR>
  1852. <A NAME="TOC23" HREF="tcc-doc.html#SEC23">8. Developer's guide</A>
  1853. <BR>
  1854. <A NAME="TOC36" HREF="tcc-doc.html#SEC36">Concept Index</A>
  1855. <BR>
  1856. </BLOCKQUOTE>
  1857. <HR SIZE=1>
  1858. <A NAME="SEC_About"></A>
  1859. <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
  1860. <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD>
  1861. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD>
  1862. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD>
  1863. <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD>
  1864. </TR></TABLE>
  1865. <H1>About this document</H1>
  1866. This document was generated on <I>March, 22 2008</I>
  1867. using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
  1868. "><I>texi2html</I></A>
  1869. <P></P>
  1870. The buttons in the navigation panels have the following meaning:
  1871. <P></P>
  1872. <table border = "1">
  1873. <TR>
  1874. <TH> Button </TH>
  1875. <TH> Name </TH>
  1876. <TH> Go to </TH>
  1877. <TH> From 1.2.3 go to</TH>
  1878. </TR>
  1879. <TR>
  1880. <TD ALIGN="CENTER">
  1881. [ &lt; ] </TD>
  1882. <TD ALIGN="CENTER">
  1883. Back
  1884. </TD>
  1885. <TD>
  1886. previous section in reading order
  1887. </TD>
  1888. <TD>
  1889. 1.2.2
  1890. </TD>
  1891. </TR>
  1892. <TR>
  1893. <TD ALIGN="CENTER">
  1894. [ &gt; ] </TD>
  1895. <TD ALIGN="CENTER">
  1896. Forward
  1897. </TD>
  1898. <TD>
  1899. next section in reading order
  1900. </TD>
  1901. <TD>
  1902. 1.2.4
  1903. </TD>
  1904. </TR>
  1905. <TR>
  1906. <TD ALIGN="CENTER">
  1907. [ &lt;&lt; ] </TD>
  1908. <TD ALIGN="CENTER">
  1909. FastBack
  1910. </TD>
  1911. <TD>
  1912. previous or up-and-previous section
  1913. </TD>
  1914. <TD>
  1915. 1.1
  1916. </TD>
  1917. </TR>
  1918. <TR>
  1919. <TD ALIGN="CENTER">
  1920. [ Up ] </TD>
  1921. <TD ALIGN="CENTER">
  1922. Up
  1923. </TD>
  1924. <TD>
  1925. up section
  1926. </TD>
  1927. <TD>
  1928. 1.2
  1929. </TD>
  1930. </TR>
  1931. <TR>
  1932. <TD ALIGN="CENTER">
  1933. [ &gt;&gt; ] </TD>
  1934. <TD ALIGN="CENTER">
  1935. FastForward
  1936. </TD>
  1937. <TD>
  1938. next or up-and-next section
  1939. </TD>
  1940. <TD>
  1941. 1.3
  1942. </TD>
  1943. </TR>
  1944. <TR>
  1945. <TD ALIGN="CENTER">
  1946. [Top] </TD>
  1947. <TD ALIGN="CENTER">
  1948. Top
  1949. </TD>
  1950. <TD>
  1951. cover (top) of document
  1952. </TD>
  1953. <TD>
  1954. &nbsp;
  1955. </TD>
  1956. </TR>
  1957. <TR>
  1958. <TD ALIGN="CENTER">
  1959. [Contents] </TD>
  1960. <TD ALIGN="CENTER">
  1961. Contents
  1962. </TD>
  1963. <TD>
  1964. table of contents
  1965. </TD>
  1966. <TD>
  1967. &nbsp;
  1968. </TD>
  1969. </TR>
  1970. <TR>
  1971. <TD ALIGN="CENTER">
  1972. [Index] </TD>
  1973. <TD ALIGN="CENTER">
  1974. Index
  1975. </TD>
  1976. <TD>
  1977. concept index
  1978. </TD>
  1979. <TD>
  1980. &nbsp;
  1981. </TD>
  1982. </TR>
  1983. <TR>
  1984. <TD ALIGN="CENTER">
  1985. [ ? ] </TD>
  1986. <TD ALIGN="CENTER">
  1987. About
  1988. </TD>
  1989. <TD>
  1990. this page
  1991. </TD>
  1992. <TD>
  1993. &nbsp;
  1994. </TD>
  1995. </TR>
  1996. </TABLE>
  1997. <P></P>
  1998. where the <STRONG> Example </STRONG> assumes that the current position
  1999. is at <STRONG> Subsubsection One-Two-Three </STRONG> of a document of
  2000. the following structure:
  2001. <UL>
  2002. <LI> 1. Section One </LI>
  2003. <UL>
  2004. <LI>1.1 Subsection One-One</LI>
  2005. <UL>
  2006. <LI> ... </LI>
  2007. </UL>
  2008. <LI>1.2 Subsection One-Two</LI>
  2009. <UL>
  2010. <LI>1.2.1 Subsubsection One-Two-One
  2011. </LI><LI>1.2.2 Subsubsection One-Two-Two
  2012. </LI><LI>1.2.3 Subsubsection One-Two-Three &nbsp; &nbsp; <STRONG>
  2013. &lt;== Current Position </STRONG>
  2014. </LI><LI>1.2.4 Subsubsection One-Two-Four
  2015. </LI></UL>
  2016. <LI>1.3 Subsection One-Three</LI>
  2017. <UL>
  2018. <LI> ... </LI>
  2019. </UL>
  2020. <LI>1.4 Subsection One-Four</LI>
  2021. </UL>
  2022. </UL>
  2023. <HR SIZE=1>
  2024. <BR>
  2025. <FONT SIZE="-1">
  2026. This document was generated
  2027. on <I>March, 22 2008</I>
  2028. using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
  2029. "><I>texi2html</I></A>
  2030. </BODY>
  2031. </HTML>