Revision: 5384244569
Author: Andreas Unterweger <and...@gmx.at>
Date: Thu Jun 17 00:25:42 2010
Log: doc: More documentation
http://code.google.com/p/gogc/source/detail?r=5384244569
Revision: 6f82345067
Author: Andreas Unterweger <and...@gmx.at>
Date: Thu Jun 17 03:46:23 2010
Log: doc: A note on the offset issue
http://code.google.com/p/gogc/source/detail?r=6f82345067
==============================================================================
Revision: 5384244569
Author: Andreas Unterweger <and...@gmx.at>
Date: Thu Jun 17 00:25:42 2010
Log: doc: More documentation
http://code.google.com/p/gogc/source/detail?r=5384244569
Modified:
/docs/latex/gogo.aux
/docs/latex/gogo.log
/docs/latex/gogo.pdf
/docs/latex/gogo.tex
/docs/latex/gogo.toc
=======================================
--- /docs/latex/gogo.aux Wed Jun 16 23:53:02 2010
+++ /docs/latex/gogo.aux Thu Jun 17 00:25:42 2010
@@ -62,40 +62,41 @@
\@writefile{toc}{\contentsline {section}{\numberline {6.1}Supported data
types}{11}{section.6.1}}
\@writefile{toc}{\contentsline {section}{\numberline {6.2}Local variables
and offset calculations}{11}{section.6.2}}
\citation{int09}
-\@writefile{toc}{\contentsline {chapter}{\numberline {7}Code
generation}{12}{chapter.7}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {7}Code
generation}{13}{chapter.7}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{lol}{\addvspace {10\p@ }}
-\@writefile{toc}{\contentsline {section}{\numberline {7.1}Assembly
output}{12}{section.7.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.2}Register
allocation}{12}{section.7.2}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.3}The generation
of arithmetical expressions}{12}{section.7.3}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.4}The generation
of assignments}{12}{section.7.4}}
-\@writefile{toc}{\contentsline {subsection}{\numberline {7.4.1}The
generation of conditional expressions}{12}{subsection.7.4.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.5}The generation
of loops}{12}{section.7.5}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.6}The generation
of functions}{13}{section.7.6}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.7}Global variable
initialization}{13}{section.7.7}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.8}String
constants}{13}{section.7.8}}
-\newlabel{String constants}{{7.8}{13}{String constants\relax
}{section.7.8}{}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.1}Assembly
output}{13}{section.7.1}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.2}Register
allocation}{13}{section.7.2}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.3}The generation
of arithmetical expressions}{13}{section.7.3}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.4}The generation
of assignments}{13}{section.7.4}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {7.4.1}The
generation of conditional expressions}{13}{subsection.7.4.1}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.5}The generation
of loops}{13}{section.7.5}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.6}The generation
of functions}{14}{section.7.6}}
+\newlabel{The generation of functions}{{7.6}{14}{The generation of
functions\relax }{section.7.6}{}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.7}Global variable
initialization}{14}{section.7.7}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.8}String
constants}{14}{section.7.8}}
+\newlabel{String constants}{{7.8}{14}{String constants\relax
}{section.7.8}{}}
\citation{var08}
\citation{var10}
\citation{var97}
\citation{var97}
-\@writefile{toc}{\contentsline {chapter}{\numberline {8}Library and run
time}{14}{chapter.8}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {8}Library and run
time}{15}{chapter.8}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{lol}{\addvspace {10\p@ }}
-\@writefile{toc}{\contentsline {section}{\numberline {8.1}I/O
syscalls}{14}{section.8.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {8.2}The memory
manager}{14}{section.8.2}}
+\@writefile{toc}{\contentsline {section}{\numberline {8.1}I/O
syscalls}{15}{section.8.1}}
+\@writefile{toc}{\contentsline {section}{\numberline {8.2}The memory
manager}{15}{section.8.2}}
\citation{var06}
-\@writefile{toc}{\contentsline {section}{\numberline {8.3}String memory
management}{15}{section.8.3}}
-\@writefile{toc}{\contentsline {section}{\numberline {8.4}Program
parameter determination}{15}{section.8.4}}
-\@writefile{toc}{\contentsline {chapter}{\numberline
{9}Building}{17}{chapter.9}}
+\@writefile{toc}{\contentsline {section}{\numberline {8.3}String memory
management}{16}{section.8.3}}
+\@writefile{toc}{\contentsline {section}{\numberline {8.4}Program
parameter determination}{16}{section.8.4}}
+\@writefile{toc}{\contentsline {chapter}{\numberline
{9}Building}{18}{chapter.9}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{lol}{\addvspace {10\p@ }}
\bibstyle{alpha}
\bibdata{gogo}
-\@writefile{toc}{\contentsline {chapter}{\numberline
{10}Testing}{18}{chapter.10}}
+\@writefile{toc}{\contentsline {chapter}{\numberline
{10}Testing}{19}{chapter.10}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{lol}{\addvspace {10\p@ }}
=======================================
--- /docs/latex/gogo.log Wed Jun 16 23:53:02 2010
+++ /docs/latex/gogo.log Thu Jun 17 00:25:42 2010
@@ -1,4 +1,4 @@
-This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
(format=pdflatex 2010.6.7) 17 JUN 2010 08:51
+This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
(format=pdflatex 2010.6.7) 17 JUN 2010 09:24
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
@@ -456,47 +456,47 @@
[]
[]
-[11]
+[11] [12]
Chapter 7.
-[12
-
-] [13]
+[13
+
+] [14]
Chapter 8.
LaTeX Font Info: Font shape `OT1/cmtt/bx/n' in size <10.95> not
available
-(Font) Font shape `OT1/cmtt/m/n' tried instead on input line
239.
-
-Underfull \hbox (badness 10000) in paragraph at lines 235--247
+(Font) Font shape `OT1/cmtt/m/n' tried instead on input line
242.
+
+Underfull \hbox (badness 10000) in paragraph at lines 238--250
[]
-[14
-
-] [15] [16]
+[15
+
+] [16] [17]
Chapter 9.
-[17
+[18
]
Chapter 10.
-Underfull \hbox (badness 10000) in paragraph at lines 265--267
+Underfull \hbox (badness 10000) in paragraph at lines 268--270
[]
LaTeX Font Info: Font shape `OMS/cmr/m/n' in size <10.95> not available
-(Font) Font shape `OMS/cmsy/m/n' tried instead on input line
268.
-(./gogo.bbl [18
-
-]) [19
+(Font) Font shape `OMS/cmsy/m/n' tried instead on input line
271.
+(./gogo.bbl [19
+
+]) [20
] (./gogo.aux) )
Here is how much of TeX's memory you used:
- 7390 strings out of 495061
- 107292 string characters out of 1182622
- 238081 words of memory out of 3000000
- 10351 multiletter control sequences out of 15000+50000
+ 7392 strings out of 495061
+ 107328 string characters out of 1182622
+ 238137 words of memory out of 3000000
+ 10352 multiletter control sequences out of 15000+50000
9595 words of font info for 34 fonts, out of 3000000 for 9000
28 hyphenation exceptions out of 8191
- 43i,8n,43p,892b,1788s stack positions out of
5000i,500n,10000p,200000b,50000s
+ 43i,8n,43p,910b,1788s stack positions out of
5000i,500n,10000p,200000b,50000s
</usr/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmbx10
.pfb></usr/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/
share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/share/texmf-
@@ -505,9 +505,9 @@
ublic/amsfonts/cm/cmsy10.pfb></usr/share/texmf-texlive/fonts/type1/public/amsfo
nts/cm/cmti10.pfb></usr/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmtt
10.pfb>
-Output written on gogo.pdf (19 pages, 180616 bytes).
+Output written on gogo.pdf (20 pages, 184014 bytes).
PDF statistics:
- 390 PDF objects out of 1000 (max. 8388607)
- 133 named destinations out of 1000 (max. 500000)
+ 395 PDF objects out of 1000 (max. 8388607)
+ 134 named destinations out of 1000 (max. 500000)
217 words of extra memory for PDF output out of 10000 (max. 10000000)
=======================================
--- /docs/latex/gogo.pdf Wed Jun 16 23:53:02 2010
+++ /docs/latex/gogo.pdf Thu Jun 17 00:25:42 2010
Binary file, no diff available.
=======================================
--- /docs/latex/gogo.tex Wed Jun 16 23:53:02 2010
+++ /docs/latex/gogo.tex Thu Jun 17 00:25:42 2010
@@ -193,10 +193,13 @@
\end{tabular}
\section{Local variables and offset calculations}
- Lorem ipsum dolor sit amet...
+ In order to be able to distinguish between parameters, local and
global variables, a global and a local symbol table as well the function's
parameters as third, virtual symbol table are used. Local variables hide
global variables of the same name by performing the symbol table lookup for
local variables and parameters first and returning the first match if there
is any.\\
+ The memory layout for local and global variables as well as
parameters is equal: the object's offset address contains the first 64 bits
of the object, the next highest address (offset address plus 64 bits)
contains the next 64 bits etc. All local and global variable offset
addresses are 64 bit aligned. The offset of an object can be calculated by
summing the aligned sizes of its predecessors in the corresponding variable
list. Doing this, it has to be taken into consideration that pointers
always occupy 8 bytes (64 bits), regardless of the type they are actually
pointing to.\\
+ Global variables start at offset 0 of the data segment, referred to
as \texttt{data+0} in the output. Subsequent global variables use ascending
offsets as described above (p.e. referred to as \texttt{data+8} for offset
8). Local variables and parameters are addressed relative to the stack
pointer \texttt{SP}, starting at offset \texttt{SP+8} for parameters with
ascending offsets as described for global variables (\texttt{SP} is
reserved for the saved instruction pointer \texttt{IP}, see \ref{The
generation of functions}). Local variables start at offset \texttt{SP-8} in
descending order (\texttt{SP-16} for the second 64 bit variable,
\texttt{SP-24} for the third etc.) in descending order. Ignoring the sign,
the offset relative to SP is still in ascending order, so the offset
calculation method as used for global variables and parameters can be
used.\\
+ As global and local variables as well as parameters share the same
offset calculation as described above, they can be treated equally with no
change of the offset calculation mechanism. When printing a reference to a
variable address in the output, the relative offset does not need to be
changed, only the reference address (the beginning of the data segment,
\texttt{data}, or \texttt{SP} respectively) and the offset's sign. This
requires the variable's kind (local, global, parameter) to be stored during
code generation until both address and offset are needed. This is done by
introducing a new field named \texttt{Global} to the \texttt{Item} type
(see next section), indicating whether an object is a global or a local
variable or a parameter, respectively.
\chapter{Code generation}
- Lorem ipsum dolor sit amet...
+ Lorem ipsum dolor sit amet...
\section{Assembly output}
Lorem ipsum dolor sit amet...
@@ -217,7 +220,7 @@
\section{The generation of loops}
Lorem ipsum dolor sit amet...
- \section{The generation of functions}
+ \section{The generation of functions} \label{The generation of
functions}
Lorem ipsum dolor sit amet...
\section{Global variable initialization}
=======================================
--- /docs/latex/gogo.toc Wed Jun 16 23:53:02 2010
+++ /docs/latex/gogo.toc Thu Jun 17 00:25:42 2010
@@ -16,20 +16,20 @@
\contentsline {chapter}{\numberline {6}Symbol table}{10}{chapter.6}
\contentsline {section}{\numberline {6.1}Supported data
types}{11}{section.6.1}
\contentsline {section}{\numberline {6.2}Local variables and offset
calculations}{11}{section.6.2}
-\contentsline {chapter}{\numberline {7}Code generation}{12}{chapter.7}
-\contentsline {section}{\numberline {7.1}Assembly output}{12}{section.7.1}
-\contentsline {section}{\numberline {7.2}Register
allocation}{12}{section.7.2}
-\contentsline {section}{\numberline {7.3}The generation of arithmetical
expressions}{12}{section.7.3}
-\contentsline {section}{\numberline {7.4}The generation of
assignments}{12}{section.7.4}
-\contentsline {subsection}{\numberline {7.4.1}The generation of
conditional expressions}{12}{subsection.7.4.1}
-\contentsline {section}{\numberline {7.5}The generation of
loops}{12}{section.7.5}
-\contentsline {section}{\numberline {7.6}The generation of
functions}{13}{section.7.6}
-\contentsline {section}{\numberline {7.7}Global variable
initialization}{13}{section.7.7}
-\contentsline {section}{\numberline {7.8}String constants}{13}{section.7.8}
-\contentsline {chapter}{\numberline {8}Library and run time}{14}{chapter.8}
-\contentsline {section}{\numberline {8.1}I/O syscalls}{14}{section.8.1}
-\contentsline {section}{\numberline {8.2}The memory
manager}{14}{section.8.2}
-\contentsline {section}{\numberline {8.3}String memory
management}{15}{section.8.3}
-\contentsline {section}{\numberline {8.4}Program parameter
determination}{15}{section.8.4}
-\contentsline {chapter}{\numberline {9}Building}{17}{chapter.9}
-\contentsline {chapter}{\numberline {10}Testing}{18}{chapter.10}
+\contentsline {chapter}{\numberline {7}Code generation}{13}{chapter.7}
+\contentsline {section}{\numberline {7.1}Assembly output}{13}{section.7.1}
+\contentsline {section}{\numberline {7.2}Register
allocation}{13}{section.7.2}
+\contentsline {section}{\numberline {7.3}The generation of arithmetical
expressions}{13}{section.7.3}
+\contentsline {section}{\numberline {7.4}The generation of
assignments}{13}{section.7.4}
+\contentsline {subsection}{\numberline {7.4.1}The generation of
conditional expressions}{13}{subsection.7.4.1}
+\contentsline {section}{\numberline {7.5}The generation of
loops}{13}{section.7.5}
+\contentsline {section}{\numberline {7.6}The generation of
functions}{14}{section.7.6}
+\contentsline {section}{\numberline {7.7}Global variable
initialization}{14}{section.7.7}
+\contentsline {section}{\numberline {7.8}String constants}{14}{section.7.8}
+\contentsline {chapter}{\numberline {8}Library and run time}{15}{chapter.8}
+\contentsline {section}{\numberline {8.1}I/O syscalls}{15}{section.8.1}
+\contentsline {section}{\numberline {8.2}The memory
manager}{15}{section.8.2}
+\contentsline {section}{\numberline {8.3}String memory
management}{16}{section.8.3}
+\contentsline {section}{\numberline {8.4}Program parameter
determination}{16}{section.8.4}
+\contentsline {chapter}{\numberline {9}Building}{18}{chapter.9}
+\contentsline {chapter}{\numberline {10}Testing}{19}{chapter.10}
==============================================================================
Revision: 6f82345067
Author: Andreas Unterweger <and...@gmx.at>
Date: Thu Jun 17 03:46:23 2010
Log: doc: A note on the offset issue
http://code.google.com/p/gogc/source/detail?r=6f82345067
Modified:
/docs/latex/gogo.log
/docs/latex/gogo.pdf
/docs/latex/gogo.tex
=======================================
--- /docs/latex/gogo.log Thu Jun 17 00:25:42 2010
+++ /docs/latex/gogo.log Thu Jun 17 03:46:23 2010
@@ -1,4 +1,4 @@
-This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
(format=pdflatex 2010.6.7) 17 JUN 2010 09:24
+This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
(format=pdflatex 2010.6.7) 17 JUN 2010 12:43
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
@@ -463,9 +463,9 @@
] [14]
Chapter 8.
LaTeX Font Info: Font shape `OT1/cmtt/bx/n' in size <10.95> not
available
-(Font) Font shape `OT1/cmtt/m/n' tried instead on input line
242.
-
-Underfull \hbox (badness 10000) in paragraph at lines 238--250
+(Font) Font shape `OT1/cmtt/m/n' tried instead on input line
243.
+
+Underfull \hbox (badness 10000) in paragraph at lines 239--251
[]
@@ -478,12 +478,12 @@
]
Chapter 10.
-Underfull \hbox (badness 10000) in paragraph at lines 268--270
+Underfull \hbox (badness 10000) in paragraph at lines 269--271
[]
LaTeX Font Info: Font shape `OMS/cmr/m/n' in size <10.95> not available
-(Font) Font shape `OMS/cmsy/m/n' tried instead on input line
271.
+(Font) Font shape `OMS/cmsy/m/n' tried instead on input line
272.
(./gogo.bbl [19
]) [20
@@ -505,7 +505,7 @@
ublic/amsfonts/cm/cmsy10.pfb></usr/share/texmf-texlive/fonts/type1/public/amsfo
nts/cm/cmti10.pfb></usr/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmtt
10.pfb>
-Output written on gogo.pdf (20 pages, 184014 bytes).
+Output written on gogo.pdf (20 pages, 184692 bytes).
PDF statistics:
395 PDF objects out of 1000 (max. 8388607)
134 named destinations out of 1000 (max. 500000)
=======================================
--- /docs/latex/gogo.pdf Thu Jun 17 00:25:42 2010
+++ /docs/latex/gogo.pdf Thu Jun 17 03:46:23 2010
Binary file, no diff available.
=======================================
--- /docs/latex/gogo.tex Thu Jun 17 00:25:42 2010
+++ /docs/latex/gogo.tex Thu Jun 17 03:46:23 2010
@@ -196,7 +196,8 @@
In order to be able to distinguish between parameters, local and
global variables, a global and a local symbol table as well the function's
parameters as third, virtual symbol table are used. Local variables hide
global variables of the same name by performing the symbol table lookup for
local variables and parameters first and returning the first match if there
is any.\\
The memory layout for local and global variables as well as
parameters is equal: the object's offset address contains the first 64 bits
of the object, the next highest address (offset address plus 64 bits)
contains the next 64 bits etc. All local and global variable offset
addresses are 64 bit aligned. The offset of an object can be calculated by
summing the aligned sizes of its predecessors in the corresponding variable
list. Doing this, it has to be taken into consideration that pointers
always occupy 8 bytes (64 bits), regardless of the type they are actually
pointing to.\\
Global variables start at offset 0 of the data segment, referred to
as \texttt{data+0} in the output. Subsequent global variables use ascending
offsets as described above (p.e. referred to as \texttt{data+8} for offset
8). Local variables and parameters are addressed relative to the stack
pointer \texttt{SP}, starting at offset \texttt{SP+8} for parameters with
ascending offsets as described for global variables (\texttt{SP} is
reserved for the saved instruction pointer \texttt{IP}, see \ref{The
generation of functions}). Local variables start at offset \texttt{SP-8} in
descending order (\texttt{SP-16} for the second 64 bit variable,
\texttt{SP-24} for the third etc.) in descending order. Ignoring the sign,
the offset relative to SP is still in ascending order, so the offset
calculation method as used for global variables and parameters can be
used.\\
- As global and local variables as well as parameters share the same
offset calculation as described above, they can be treated equally with no
change of the offset calculation mechanism. When printing a reference to a
variable address in the output, the relative offset does not need to be
changed, only the reference address (the beginning of the data segment,
\texttt{data}, or \texttt{SP} respectively) and the offset's sign. This
requires the variable's kind (local, global, parameter) to be stored during
code generation until both address and offset are needed. This is done by
introducing a new field named \texttt{Global} to the \texttt{Item} type
(see next section), indicating whether an object is a global or a local
variable or a parameter, respectively.
+ As global and local variables as well as parameters share the same
offset calculation as described above, they can be treated equally with no
change of the offset calculation mechanism. When printing a reference to a
variable address in the output, the relative offset does not need to be
changed, only the reference address (the beginning of the data segment,
\texttt{data}, or \texttt{SP} respectively) and the offset's sign. This
requires the variable's kind (local, global, parameter) to be stored during
code generation until both address and offset are needed. This is done by
introducing a new field named \texttt{Global} to the \texttt{Item} type
(see next section), indicating whether an object is a global or a local
variable or a parameter, respectively.\\
+ Offset calculations within types (p.e. calculating the field offsets
in a struct or an array index) require a slightly different handling.
Global variables as well as parameters can be treated the same way as
explained above as their internal offsets' ascending order corresponds to
their memory layout (ascending addresses). Local variables require a
different calculation as their memory layout (descending addresses)
differs. This is necessary in order to be able to assign global to local
variables and vice verse so that their internal memory layouts correspond
from the programmer's point of view. This is also done by a distinction
based on the item's \texttt{Global} flag as explained above: during code
generation, the internal offset of a local variable has to be calculated by
subtraction instead of addition due to the negative sign of the offset.