⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcc-doc.html

📁 SQLite ODBC Driver SQLite3 的ODBC驱动
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<HR SIZE="6"><A NAME="SEC27"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC26"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC28"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD><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><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD></TR></TABLE><H2> 8.4 Types </H2><!--docid::SEC27::--><P>The types are stored in a single 'int' variable. It was choosen in thefirst stages of development when tcc was much simpler. Now, it may notbe the best solution.</P><P><TABLE><tr><td>&nbsp;</td><td class=example><pre>#define VT_INT        0  /* integer type */#define VT_BYTE       1  /* signed byte type */#define VT_SHORT      2  /* short type */#define VT_VOID       3  /* void type */#define VT_PTR        4  /* pointer */#define VT_ENUM       5  /* enum definition */#define VT_FUNC       6  /* function type */#define VT_STRUCT     7  /* struct/union definition */#define VT_FLOAT      8  /* IEEE float */#define VT_DOUBLE     9  /* IEEE double */#define VT_LDOUBLE   10  /* IEEE long double */#define VT_BOOL      11  /* ISOC99 boolean type */#define VT_LLONG     12  /* 64 bit integer */#define VT_LONG      13  /* long integer (NEVER USED as type, only                            during parsing) */#define VT_BTYPE      0x000f /* mask for basic type */#define VT_UNSIGNED   0x0010  /* unsigned type */#define VT_ARRAY      0x0020  /* array type (also has VT_PTR) */#define VT_BITFIELD   0x0040  /* bitfield modifier */#define VT_STRUCT_SHIFT 16   /* structure/enum name shift (16 bits left) */</pre></td></tr></table></P><P>When a reference to another type is needed (for pointers, functions andstructures), the <CODE>32 - VT_STRUCT_SHIFT</CODE> high order bits are used tostore an identifier reference.</P><P>The <CODE>VT_UNSIGNED</CODE> flag can be set for chars, shorts, ints and longlongs.</P><P>Arrays are considered as pointers <CODE>VT_PTR</CODE> with the flag<CODE>VT_ARRAY</CODE> set.</P><P>The <CODE>VT_BITFIELD</CODE> flag can be set for chars, shorts, ints and longlongs. If it is set, then the bitfield position is stored from bitsVT_STRUCT_SHIFT to VT_STRUCT_SHIFT + 5 and the bit field size is storedfrom bits VT_STRUCT_SHIFT + 6 to VT_STRUCT_SHIFT + 11.</P><P><CODE>VT_LONG</CODE> is never used except during parsing.</P><P>During parsing, the storage of an object is also stored in the typeinteger:</P><P><TABLE><tr><td>&nbsp;</td><td class=example><pre>#define VT_EXTERN  0x00000080  /* extern definition */#define VT_STATIC  0x00000100  /* static variable */#define VT_TYPEDEF 0x00000200  /* typedef definition */</pre></td></tr></table></P><P><HR SIZE="6"><A NAME="SEC28"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC27"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC29"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD><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><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD></TR></TABLE><H2> 8.5 Symbols </H2><!--docid::SEC28::--><P>All symbols are stored in hashed symbol stacks. Each symbol stackcontains <CODE>Sym</CODE> structures.</P><P><CODE>Sym.v</CODE> contains the symbol name (rememberan idenfier is also a token, so a string is never necessary to storeit). <CODE>Sym.t</CODE> gives the type of the symbol. <CODE>Sym.r</CODE> is usuallythe register in which the corresponding variable is stored. <CODE>Sym.c</CODE> isusually a constant associated to the symbol.</P><P>Four main symbol stacks are defined:</P><P><DL COMPACT><DT><CODE>define_stack</CODE><DD>for the macros (<CODE>#define</CODE>s).<P><DT><CODE>global_stack</CODE><DD>for the global variables, functions and types.<P><DT><CODE>local_stack</CODE><DD>for the local variables, functions and types.<P><DT><CODE>global_label_stack</CODE><DD>for the local labels (for <CODE>goto</CODE>).<P><DT><CODE>label_stack</CODE><DD>for GCC block local labels (see the <CODE>__label__</CODE> keyword).<P></DL><P><CODE>sym_push()</CODE> is used to add a new symbol in the local symbolstack. If no local symbol stack is active, it is added in the globalsymbol stack.</P><P><CODE>sym_pop(st,b)</CODE> pops symbols from the symbol stack <VAR>st</VAR> untilthe symbol <VAR>b</VAR> is on the top of stack. If <VAR>b</VAR> is NULL, the stackis emptied.</P><P><CODE>sym_find(v)</CODE> return the symbol associated to the identifier<VAR>v</VAR>. The local stack is searched first from top to bottom, then theglobal stack.</P><P><HR SIZE="6"><A NAME="SEC29"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC28"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD><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><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD></TR></TABLE><H2> 8.6 Sections </H2><!--docid::SEC29::--><P>The generated code and datas are written in sections. The structure<CODE>Section</CODE> contains all the necessary information for a givensection. <CODE>new_section()</CODE> creates a new section. ELF file semanticsis assumed for each section.</P><P>The following sections are predefined:</P><P><DL COMPACT><DT><CODE>text_section</CODE><DD>is the section containing the generated code. <VAR>ind</VAR> contains thecurrent position in the code section.<P><DT><CODE>data_section</CODE><DD>contains initialized data<P><DT><CODE>bss_section</CODE><DD>contains uninitialized data<P><DT><CODE>bounds_section</CODE><DD><DT><CODE>lbounds_section</CODE><DD>are used when bound checking is activated<P><DT><CODE>stab_section</CODE><DD><DT><CODE>stabstr_section</CODE><DD>are used when debugging is actived to store debug information<P><DT><CODE>symtab_section</CODE><DD><DT><CODE>strtab_section</CODE><DD>contain the exported symbols (currently only used for debugging).<P></DL><P><HR SIZE="6"><A NAME="SEC30"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC29"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC31"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD><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><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD></TR></TABLE><H2> 8.7 Code generation </H2><!--docid::SEC30::--><P><HR SIZE="6"><A NAME="SEC31"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC30"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC32"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD><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><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD></TR></TABLE><H3> 8.7.1 Introduction </H3><!--docid::SEC31::--><P>The TCC code generator directly generates linked binary code in onepass. It is rather unusual these days (see gcc for example whichgenerates text assembly), but it can be very fast and surprisinglylittle complicated.</P><P>The TCC code generator is register based. Optimization is only done atthe expression level. No intermediate representation of expression iskept except the current values stored in the <EM>value stack</EM>.</P><P>On x86, three temporary registers are used. When more registers areneeded, one register is spilled into a new temporary variable on the stack.</P><P><HR SIZE="6"><A NAME="SEC32"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC31"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC33"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ &gt;&gt; ]</TD><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><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD></TR></TABLE><H3> 8.7.2 The value stack </H3><!--docid::SEC32::--><P>When an expression is parsed, its value is pushed on the value stack(<VAR>vstack</VAR>). The top of the value stack is <VAR>vtop</VAR>. Each valuestack entry is the structure <CODE>SValue</CODE>.</P><P><CODE>SValue.t</CODE> is the type. <CODE>SValue.r</CODE> indicates how the value iscurrently stored in the generated code. It is usually a CPU registerindex (<CODE>REG_xxx</CODE> constants), but additional values and flags aredefined:</P><P><TABLE><tr><td>&nbsp;</td><td class=example><pre>#define VT_CONST     0x00f0#define VT_LLOCAL    0x00f1#define VT_LOCAL     0x00f2#define VT_CMP       0x00f3#define VT_JMP       0x00f4#define VT_JMPI      0x00f5#define VT_LVAL      0x0100#define VT_SYM       0x0200#define VT_MUSTCAST  0x0400#define VT_MUSTBOUND 0x0800#define VT_BOUNDED   0x8000#define VT_LVAL_BYTE     0x1000#define VT_LVAL_SHORT    0x2000#define VT_LVAL_UNSIGNED 0x4000#define VT_LVAL_TYPE     (VT_LVAL_BYTE | VT_LVAL_SHORT | VT_LVAL_UNSIGNED)</pre></td></tr></table></P><P><DL COMPACT><DT><CODE>VT_CONST</CODE><DD>indicates that the value is a constant. It is stored in the union<CODE>SValue.c</CODE>, depending on its type.<P><DT><CODE>VT_LOCAL</CODE><DD>indicates a local variable pointer at offset <CODE>SValue.c.i</CODE> in thestack.<P><DT><CODE>VT_CMP</CODE><DD>indicates that the value is actually stored in the CPU flags (i.e. thevalue is the consequence of a test). The value is either 0 or 1. Theactual CPU flags used is indicated in <CODE>SValue.c.i</CODE>. <P>If any code is generated which destroys the CPU flags, this value MUST beput in a normal register.</P><P><DT><CODE>VT_JMP</CODE><DD><DT><CODE>VT_JMPI</CODE><DD>indicates that the value is the consequence of a conditional jump. For VT_JMP,it is 1 if the jump is taken, 0 otherwise. For VT_JMPI it is inverted.<P>These values are used to compile the <CODE>||</CODE> and <CODE>&#38;&#38;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -