[gogc] 2 new revisions pushed by bytbox on 2010-08-18 01:00 GMT

0 views
Skip to first unread message

go...@googlecode.com

unread,
Aug 17, 2010, 11:55:43 PM8/17/10
to go...@googlegroups.com
2 new revisions:

Revision: 85813f4472
Author: Andreas Unterweger <and...@gmx.at>
Date: Sat Jun 26 06:17:59 2010
Log: docs: Some more documentation (not much, but enough for today ;)
http://code.google.com/p/gogc/source/detail?r=85813f4472

Revision: 09e25f53e7
Author: Andreas Unterweger <and...@gmx.at>
Date: Sat Jun 26 09:43:06 2010
Log: docs: Some more documentation (enough for today)
http://code.google.com/p/gogc/source/detail?r=09e25f53e7

==============================================================================
Revision: 85813f4472
Author: Andreas Unterweger <and...@gmx.at>
Date: Sat Jun 26 06:17:59 2010
Log: docs: Some more documentation (not much, but enough for today ;)
http://code.google.com/p/gogc/source/detail?r=85813f4472

Modified:
/docs/latex/gogo.aux
/docs/latex/gogo.log
/docs/latex/gogo.out
/docs/latex/gogo.pdf
/docs/latex/gogo.tex
/docs/latex/gogo.toc

=======================================
--- /docs/latex/gogo.aux Thu Jun 17 00:25:42 2010
+++ /docs/latex/gogo.aux Sat Jun 26 06:17:59 2010
@@ -61,6 +61,9 @@
\@writefile{lol}{\addvspace {10\p@ }}
\@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{pik00}
+\citation{int09}
+\citation{wir96}
\citation{int09}
\@writefile{toc}{\contentsline {chapter}{\numberline {7}Code
generation}{13}{chapter.7}}
\@writefile{lof}{\addvspace {10\p@ }}
@@ -68,35 +71,35 @@
\@writefile{lol}{\addvspace {10\p@ }}
\@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}{}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.3}The generation
of arithmetical expressions}{14}{section.7.3}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.4}The generation
of assignments}{14}{section.7.4}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.5}The generation
of conditional expressions}{14}{section.7.5}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.6}The generation
of loops}{14}{section.7.6}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.7}The generation
of functions}{14}{section.7.7}}
+\newlabel{The generation of functions}{{7.7}{14}{The generation of
functions\relax }{section.7.7}{}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.8}Global variable
initialization}{14}{section.7.8}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.9}String
constants}{15}{section.7.9}}
+\newlabel{String constants}{{7.9}{15}{String constants\relax
}{section.7.9}{}}
\citation{var08}
\citation{var10}
\citation{var97}
\citation{var97}
-\@writefile{toc}{\contentsline {chapter}{\numberline {8}Library and run
time}{15}{chapter.8}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {8}Library and run
time}{16}{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}{15}{section.8.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {8.2}The memory
manager}{15}{section.8.2}}
+\@writefile{toc}{\contentsline {section}{\numberline {8.1}I/O
syscalls}{16}{section.8.1}}
+\@writefile{toc}{\contentsline {section}{\numberline {8.2}The memory
manager}{16}{section.8.2}}
\citation{var06}
-\@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{toc}{\contentsline {section}{\numberline {8.3}String memory
management}{17}{section.8.3}}
+\@writefile{toc}{\contentsline {section}{\numberline {8.4}Program
parameter determination}{17}{section.8.4}}
+\@writefile{toc}{\contentsline {chapter}{\numberline
{9}Building}{19}{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}{19}{chapter.10}}
+\@writefile{toc}{\contentsline {chapter}{\numberline
{10}Testing}{20}{chapter.10}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{lol}{\addvspace {10\p@ }}
=======================================
--- /docs/latex/gogo.log Thu Jun 17 03:46:23 2010
+++ /docs/latex/gogo.log Sat Jun 26 06:17:59 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 12:43
+This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
(format=pdflatex 2010.6.7) 26 JUN 2010 15:16
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
@@ -460,43 +460,43 @@
Chapter 7.
[13

-] [14]
+] [14] [15]
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
243.
-
-Underfull \hbox (badness 10000) in paragraph at lines 239--251
+(Font) Font shape `OT1/cmtt/m/n' tried instead on input line
246.
+
+Underfull \hbox (badness 10000) in paragraph at lines 242--254

[]

-[15
-
-] [16] [17]
+[16
+
+] [17] [18]
Chapter 9.
-[18
+[19

]
Chapter 10.

-Underfull \hbox (badness 10000) in paragraph at lines 269--271
+Underfull \hbox (badness 10000) in paragraph at lines 272--274

[]

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
272.
-(./gogo.bbl [19
-
-]) [20
+(Font) Font shape `OMS/cmsy/m/n' tried instead on input line
275.
+(./gogo.bbl [20
+
+]) [21

] (./gogo.aux) )
Here is how much of TeX's memory you used:
- 7392 strings out of 495061
- 107328 string characters out of 1182622
+ 7393 strings out of 495061
+ 107325 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,910b,1788s stack positions out of
5000i,500n,10000p,200000b,50000s
+ 43i,8n,43p,916b,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 (20 pages, 184692 bytes).
+Output written on gogo.pdf (21 pages, 188982 bytes).
PDF statistics:
- 395 PDF objects out of 1000 (max. 8388607)
- 134 named destinations out of 1000 (max. 500000)
+ 402 PDF objects out of 1000 (max. 8388607)
+ 135 named destinations out of 1000 (max. 500000)
217 words of extra memory for PDF output out of 10000 (max. 10000000)

=======================================
--- /docs/latex/gogo.out Wed Jun 16 23:53:02 2010
+++ /docs/latex/gogo.out Sat Jun 26 06:17:59 2010
@@ -13,11 +13,11 @@
\BOOKMARK [1][-]{section.7.2}{Register allocation}{chapter.7}
\BOOKMARK [1][-]{section.7.3}{The generation of arithmetical
expressions}{chapter.7}
\BOOKMARK [1][-]{section.7.4}{The generation of assignments}{chapter.7}
-\BOOKMARK [2][-]{subsection.7.4.1}{The generation of conditional
expressions}{section.7.4}
-\BOOKMARK [1][-]{section.7.5}{The generation of loops}{chapter.7}
-\BOOKMARK [1][-]{section.7.6}{The generation of functions}{chapter.7}
-\BOOKMARK [1][-]{section.7.7}{Global variable initialization}{chapter.7}
-\BOOKMARK [1][-]{section.7.8}{String constants}{chapter.7}
+\BOOKMARK [1][-]{section.7.5}{The generation of conditional
expressions}{chapter.7}
+\BOOKMARK [1][-]{section.7.6}{The generation of loops}{chapter.7}
+\BOOKMARK [1][-]{section.7.7}{The generation of functions}{chapter.7}
+\BOOKMARK [1][-]{section.7.8}{Global variable initialization}{chapter.7}
+\BOOKMARK [1][-]{section.7.9}{String constants}{chapter.7}
\BOOKMARK [0][-]{chapter.8}{Library and run time}{}
\BOOKMARK [1][-]{section.8.1}{I/O syscalls}{chapter.8}
\BOOKMARK [1][-]{section.8.2}{The memory manager}{chapter.8}
=======================================
--- /docs/latex/gogo.pdf Thu Jun 17 03:46:23 2010
+++ /docs/latex/gogo.pdf Sat Jun 26 06:17:59 2010
Binary file, no diff available.
=======================================
--- /docs/latex/gogo.tex Thu Jun 17 03:46:23 2010
+++ /docs/latex/gogo.tex Sat Jun 26 06:17:59 2010
@@ -200,22 +200,25 @@
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.

\chapter{Code generation}
- Lorem ipsum dolor sit amet...
+ GoGo emits assembly code in text form based on the Go input files.
This section briefly explains the main features implemented in the code
generating functions of GoGo.

\section{Assembly output}
- Lorem ipsum dolor sit amet...
+ GoGo creates an output file with assembly instructions and comments
using mnemonics for op codes and operands/registers which means that it
outputs in text form, not in binary form. Thereforce, an assembler is
needed to process the output in order to make it executable. Like the Go
compiler, GoGo relies on \texttt{6a} and \texttt{6l} of the Plan9 tools in
order to acomplish this\cite{pik00}.\\
+ The assembly output consists basically of three sections: the data
segment, the initialization segment and the code segment. GoGo's assembly
output framework provides basic output routines which make it possible to
switch between those three segments. Whereas the data segment is used to
reserve space for global variables and strings in the data segment, the
initialization segment and the code segment contain the code for global
variable initialization and the functions from the input, respectively. All
other functions (code generation for arithmetical expressions etc.) rely on
the assembly output framework which is also able to place comments with the
corresponding input file name and line number for debugging purposes in the
output file.

\section{Register allocation}
The target architecture provides 8 general purpose registers
(\texttt{R8}-\texttt{R15}) as well as the registers \texttt{RAX},
\texttt{RBX}, \texttt{RCX} and \texttt{RDX}\cite{int09}. The latter are not
being used by GoGo to store variables as their values may change when
performing arithmetical operations (p.e. \texttt{RAX} and \texttt{RDX} are
always used as the destination registers for multiplications), thus
possibly overwriting values previously stored there.\\
GoGo stores a list for every one of the 8 registers currently
free, returning the first free register if required by the code generator.
Whenever a register is no longer required (freed), it will be reinserted
into the "free" list in order to make it available for future use. Due to
the limited amout of registers, the list described is implemented in form
of a bit array in the compiler.

\section{The generation of arithmetical expressions}
- Lorem ipsum dolor sit amet...
+ As described in \cite{wir96}, code generation for arithmetical
expressions basically relies on an operand stack and delayed code
generation based on \texttt{Items}. For constant operands, constant folding
is applied; variable operands are loaded into a free register in order to
perform arithmetical operations on them.\\
+ GoGo makes use of the capabilities of the target architecture by not
loading constants into registers, thus reducing the number of registers
required. Consider the expression \texttt{a + 1} where \texttt{a} is a
variable of type \texttt{uint64}. As the target architecture is able to
perform an operation like \texttt{ADDQ R8, \$1} (add 1 to the register R8),
only \texttt{a} needs to be loaded into a register, whereas 1 can be used
directly be incorporated into the instruction itself.\\
+ Multiplication and division on the target architecture both require
special treatment: The multiplication instruction only takes the second
operand and requires the first operand to be in the register
\texttt{RAX}\cite{int09}. Therefore, the first operand has to be loaded
into \texttt{RAX} prior multiplication. The multiplication result is stored
as 128 bit value in \texttt{RDX} (upper 64 bits) and \texttt{RAX} (lower 64
bits). As GoGo does not support data types other than \texttt{byte} and
\texttt{uint64}, the upper 64 bits in \texttt{RDX} are ignored, and the
lower 64 bits are moved to one of the 8 registers to save the result before
another multiplication is being performed. Similarly, division allows for
an 128 bit operand (also in \texttt{RDX} and \texttt{RAX}). As GoGo does
not support 128 bit size data types, \texttt{RDX} is always being zeroed
prior division.

\section{The generation of assignments}
Lorem ipsum dolor sit amet...

- \subsection{The generation of conditional expressions}
+ \section{The generation of conditional expressions}
Lorem ipsum dolor sit amet...

\section{The generation of loops}
=======================================
--- /docs/latex/gogo.toc Thu Jun 17 00:25:42 2010
+++ /docs/latex/gogo.toc Sat Jun 26 06:17:59 2010
@@ -19,17 +19,17 @@
\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}
+\contentsline {section}{\numberline {7.3}The generation of arithmetical
expressions}{14}{section.7.3}
+\contentsline {section}{\numberline {7.4}The generation of
assignments}{14}{section.7.4}
+\contentsline {section}{\numberline {7.5}The generation of conditional
expressions}{14}{section.7.5}
+\contentsline {section}{\numberline {7.6}The generation of
loops}{14}{section.7.6}
+\contentsline {section}{\numberline {7.7}The generation of
functions}{14}{section.7.7}
+\contentsline {section}{\numberline {7.8}Global variable
initialization}{14}{section.7.8}
+\contentsline {section}{\numberline {7.9}String constants}{15}{section.7.9}
+\contentsline {chapter}{\numberline {8}Library and run time}{16}{chapter.8}
+\contentsline {section}{\numberline {8.1}I/O syscalls}{16}{section.8.1}
+\contentsline {section}{\numberline {8.2}The memory
manager}{16}{section.8.2}
+\contentsline {section}{\numberline {8.3}String memory
management}{17}{section.8.3}
+\contentsline {section}{\numberline {8.4}Program parameter
determination}{17}{section.8.4}
+\contentsline {chapter}{\numberline {9}Building}{19}{chapter.9}
+\contentsline {chapter}{\numberline {10}Testing}{20}{chapter.10}

==============================================================================
Revision: 09e25f53e7
Author: Andreas Unterweger <and...@gmx.at>
Date: Sat Jun 26 09:43:06 2010
Log: docs: Some more documentation (enough for today)
http://code.google.com/p/gogc/source/detail?r=09e25f53e7

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 Sat Jun 26 06:17:59 2010
+++ /docs/latex/gogo.aux Sat Jun 26 09:43:06 2010
@@ -73,33 +73,33 @@
\@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}{14}{section.7.3}}
\@writefile{toc}{\contentsline {section}{\numberline {7.4}The generation
of assignments}{14}{section.7.4}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.5}The generation
of conditional expressions}{14}{section.7.5}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.6}The generation
of loops}{14}{section.7.6}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.7}The generation
of functions}{14}{section.7.7}}
-\newlabel{The generation of functions}{{7.7}{14}{The generation of
functions\relax }{section.7.7}{}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.8}Global variable
initialization}{14}{section.7.8}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.9}String
constants}{15}{section.7.9}}
-\newlabel{String constants}{{7.9}{15}{String constants\relax
}{section.7.9}{}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.5}The generation
of conditional expressions}{15}{section.7.5}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.6}The generation
of loops}{15}{section.7.6}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.7}The generation
of functions}{15}{section.7.7}}
+\newlabel{The generation of functions}{{7.7}{15}{The generation of
functions\relax }{section.7.7}{}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.8}Global variable
initialization}{15}{section.7.8}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.9}String
constants}{16}{section.7.9}}
+\newlabel{String constants}{{7.9}{16}{String constants\relax
}{section.7.9}{}}
\citation{var08}
\citation{var10}
\citation{var97}
\citation{var97}
-\@writefile{toc}{\contentsline {chapter}{\numberline {8}Library and run
time}{16}{chapter.8}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {8}Library and run
time}{17}{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}{16}{section.8.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {8.2}The memory
manager}{16}{section.8.2}}
+\@writefile{toc}{\contentsline {section}{\numberline {8.1}I/O
syscalls}{17}{section.8.1}}
+\@writefile{toc}{\contentsline {section}{\numberline {8.2}The memory
manager}{17}{section.8.2}}
\citation{var06}
-\@writefile{toc}{\contentsline {section}{\numberline {8.3}String memory
management}{17}{section.8.3}}
-\@writefile{toc}{\contentsline {section}{\numberline {8.4}Program
parameter determination}{17}{section.8.4}}
-\@writefile{toc}{\contentsline {chapter}{\numberline
{9}Building}{19}{chapter.9}}
+\@writefile{toc}{\contentsline {section}{\numberline {8.3}String memory
management}{18}{section.8.3}}
+\@writefile{toc}{\contentsline {section}{\numberline {8.4}Program
parameter determination}{18}{section.8.4}}
+\@writefile{toc}{\contentsline {chapter}{\numberline
{9}Building}{20}{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}{20}{chapter.10}}
+\@writefile{toc}{\contentsline {chapter}{\numberline
{10}Testing}{21}{chapter.10}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{lol}{\addvspace {10\p@ }}
=======================================
--- /docs/latex/gogo.log Sat Jun 26 06:17:59 2010
+++ /docs/latex/gogo.log Sat Jun 26 09:43:06 2010
@@ -1,4 +1,4 @@
-This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
(format=pdflatex 2010.6.7) 26 JUN 2010 15:16
+This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
(format=pdflatex 2010.6.7) 26 JUN 2010 18:42
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
@@ -456,58 +456,83 @@
[]
[]

+
+Underfull \hbox (badness 10000) in paragraph at lines 196--211
+
+ []
+
+
+Underfull \hbox (badness 10000) in paragraph at lines 196--211
+
+ []
+
[11] [12]
Chapter 7.
[13

-] [14] [15]
+]
+Underfull \hbox (badness 10000) in paragraph at lines 230--244
+
+ []
+
+
+Overfull \hbox (16.95285pt too wide) in paragraph at lines 230--244
+[]
+ []
+
+
+Underfull \hbox (badness 10000) in paragraph at lines 230--244
+
+ []
+
+[14] [15] [16]
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
246.
-
-Underfull \hbox (badness 10000) in paragraph at lines 242--254
+(Font) Font shape `OT1/cmtt/m/n' tried instead on input line
270.
+
+Underfull \hbox (badness 10000) in paragraph at lines 266--278

[]

-[16
-
-] [17] [18]
+[17
+
+] [18] [19]
Chapter 9.
-[19
+[20

]
Chapter 10.

-Underfull \hbox (badness 10000) in paragraph at lines 272--274
+Underfull \hbox (badness 10000) in paragraph at lines 296--298

[]

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
275.
-(./gogo.bbl [20
-
-]) [21
+(Font) Font shape `OMS/cmsy/m/n' tried instead on input line
299.
+(./gogo.bbl [21
+
+]) [22

] (./gogo.aux) )
Here is how much of TeX's memory you used:
- 7393 strings out of 495061
- 107325 string characters out of 1182622
+ 7396 strings out of 495061
+ 107358 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
+ 10353 multiletter control sequences out of 15000+50000
+ 9763 words of font info for 35 fonts, out of 3000000 for 9000
28 hyphenation exceptions out of 8191
- 43i,8n,43p,916b,1788s stack positions out of
5000i,500n,10000p,200000b,50000s
+ 43i,8n,43p,938b,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-
-texlive/fonts/type1/public/amsfonts/cm/cmr12.pfb></usr/share/texmf-texlive/font
-s/type1/public/amsfonts/cm/cmssbx10.pfb></usr/share/texmf-texlive/fonts/type1/p
-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 (21 pages, 188982 bytes).
+.pfb></usr/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmitt10.pfb></usr
+/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/share/texm
+f-texlive/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/share/texmf-texlive/fo
+nts/type1/public/amsfonts/cm/cmr12.pfb></usr/share/texmf-texlive/fonts/type1/pu
+blic/amsfonts/cm/cmssbx10.pfb></usr/share/texmf-texlive/fonts/type1/public/amsf
+onts/cm/cmsy10.pfb></usr/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmt
+i10.pfb></usr/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmtt10.pfb>
+Output written on gogo.pdf (22 pages, 199605 bytes).
PDF statistics:
- 402 PDF objects out of 1000 (max. 8388607)
- 135 named destinations out of 1000 (max. 500000)
+ 410 PDF objects out of 1000 (max. 8388607)
+ 136 named destinations out of 1000 (max. 500000)
217 words of extra memory for PDF output out of 10000 (max. 10000000)

=======================================
--- /docs/latex/gogo.pdf Sat Jun 26 06:17:59 2010
+++ /docs/latex/gogo.pdf Sat Jun 26 09:43:06 2010
Binary file, no diff available.
=======================================
--- /docs/latex/gogo.tex Sat Jun 26 06:17:59 2010
+++ /docs/latex/gogo.tex Sat Jun 26 09:43:06 2010
@@ -195,9 +195,19 @@
\section{Local variables and offset calculations}
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.\\
+ 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., see table below) 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.\\ \\
+ \begin{tabular}{|l|l|p{2cm}l}
+ \cline{1-2}
+ \textbf{Address} & \textbf{Content} & & \textbf{Source code}\\
\cline{1-2}
+ \texttt{SP - 0} & Saved \texttt{IP} & & \\ \cline{1-2}
+ \texttt{SP - 8} & \texttt{a} & & \texttt{var a uint64;}\\
\cline{1-2}
+ \texttt{SP - 16} & \texttt{b} & & \texttt{var b uint64;}\\
\cline{1-2}
+ \texttt{SP - 24} & \texttt{c} & & \texttt{var c uint64;}\\
\cline{1-2}
+ \texttt{SP - 32} & \texttt{s} (higher 8 bytes) & & \texttt{var s
string;}\\ \cline{1-2}
+ \texttt{SP - 40} & \texttt{s} (lower 8 bytes) & & \\ \cline{1-2}
+ \end{tabular}\\ \\
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.
+ 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
(also see table above).

\chapter{Code generation}
GoGo emits assembly code in text form based on the Go input files.
This section briefly explains the main features implemented in the code
generating functions of GoGo.
@@ -212,11 +222,25 @@

\section{The generation of arithmetical expressions}
As described in \cite{wir96}, code generation for arithmetical
expressions basically relies on an operand stack and delayed code
generation based on \texttt{Items}. For constant operands, constant folding
is applied; variable operands are loaded into a free register in order to
perform arithmetical operations on them.\\
- GoGo makes use of the capabilities of the target architecture by not
loading constants into registers, thus reducing the number of registers
required. Consider the expression \texttt{a + 1} where \texttt{a} is a
variable of type \texttt{uint64}. As the target architecture is able to
perform an operation like \texttt{ADDQ R8, \$1} (add 1 to the register R8),
only \texttt{a} needs to be loaded into a register, whereas 1 can be used
directly be incorporated into the instruction itself.\\
- Multiplication and division on the target architecture both require
special treatment: The multiplication instruction only takes the second
operand and requires the first operand to be in the register
\texttt{RAX}\cite{int09}. Therefore, the first operand has to be loaded
into \texttt{RAX} prior multiplication. The multiplication result is stored
as 128 bit value in \texttt{RDX} (upper 64 bits) and \texttt{RAX} (lower 64
bits). As GoGo does not support data types other than \texttt{byte} and
\texttt{uint64}, the upper 64 bits in \texttt{RDX} are ignored, and the
lower 64 bits are moved to one of the 8 registers to save the result before
another multiplication is being performed. Similarly, division allows for
an 128 bit operand (also in \texttt{RDX} and \texttt{RAX}). As GoGo does
not support 128 bit size data types, \texttt{RDX} is always being zeroed
prior division.
+ GoGo makes use of the capabilities of the target architecture by not
loading constants into registers, thus reducing the number of registers
required. Consider the expression \texttt{a + b} where both \texttt{a} and
\texttt{b} are variables of type \texttt{uint64} with negative offsets 8
and 16 relative to the stack pointer. As the target architecture is able to
perform an operation like \texttt{ADDQ R8, -16(SP)} (add the value at
address \texttt{SP-16} to the register \texttt{R8}), only \texttt{a} needs
to be loaded into a register, whereas \texttt{b} can be directly
incorporated into the instruction itself.\\
+ Multiplication and division on the target architecture both require
special treatment: The multiplication instruction only takes the second
operand and requires the first operand to be in the register
\texttt{RAX}\cite{int09}. Therefore, the first operand has to be loaded
into \texttt{RAX} prior multiplication. The multiplication result is stored
as 128 bit value in \texttt{RDX} (upper 64 bits) and \texttt{RAX} (lower 64
bits). As GoGo does not support data types other than \texttt{byte} and
\texttt{uint64}, the upper 64 bits in \texttt{RDX} are ignored, and the
lower 64 bits are moved to one of the 8 registers to save the result before
another multiplication is being performed. Similarly, division allows for
an 128 bit operand (also in \texttt{RDX} and \texttt{RAX}). As GoGo does
not support 128 bit size data types, \texttt{RDX} is always being zeroed
prior division.\\
+ The addition and substraction operations are also used for offset
calculations, although an additional distinction per \texttt{Item} is
required in order to be able to distinguish addresses and values stored in
registers. As arithmetical operations on \texttt{bytes} and \texttt{uint64}
types always operate on a value, the actual value to be calculated with has
to be loaded prior calculation. As offset calculations always require the
address to be loaded into the register instead of the value, it has to be
made sure that the address is loaded, not the value. In order to
distinguish addresses and values in registers, the \texttt{A} field of the
\texttt{Item} structure is used. Additionally, the code generation routines
for addition and subtraction have an additional parameter specifying
whether to calculate with addresses or values, issuing the necessary
dereferencing operations if required.

\section{The generation of assignments}
- Lorem ipsum dolor sit amet...
+ As pointer types are supported, type checks in assignments as well
as the assignments themselves get harder to implement as additional cases
have to be dealt with. Additionally, the possible occurrence of the address
operator (\texttt{\&}) on the right hand side of an assignment doubles the
number of cases. The following table illustrates the distinctions made and
the code generated for some of the cases allowed by the EBNF (* denotes
pointer types, LHS and RHS are the \texttt{Items} on the left and right
hand side, respectively). For the sake of clearity, only the cases with a
non-pointer type variable \texttt{Item} on the left hand side and no
address operator on the right hand side using \texttt{uint64} types are
shown. The compiler is also able to assign \texttt{byte} values to one
another as well as to \texttt{uint64} types.\\ \\
+ \begin{tabular}{|l|l|l|}
+ \hline
+ \textbf{LHS type} & \textbf{RHS type} & \textbf{Code/Error
generated}\\ \hline
+ Variable & Constant & \texttt{MOVQ \$RHS.A, (LHS.A)}\\ \hline
+ Variable & Constant* & Type error\\ \hline
+ Variable & Variable & \texttt{MOVQ (RHS.A), R\textit{temp} | MOVQ
R\textit{temp}, (LHS.A)}\\ \hline
+ Variable & Variable* & Type error\\ \hline
+ Variable & Register with value & \texttt{MOVQ RHS.R, (LHS.A)}\\
\hline
+ Variable & Register with value* & Type error\\ \hline
+ Variable & Register with address & \texttt{MOVQ (RHS.R), RHS.R |
MOVQ RHS.R, (LHS.A)}\\ \hline
+ Variable & Register with address* & Type error\\ \hline
+ \end{tabular}\\ \\
+ String assignments are handled separately as they require 16 bytes
to be assigned. As one register can only hold 8 bytes, a second register
needs to be allocated in order to perform the assignment. Although this may
not be necessary in trivial cases where one string variable is assigned to
another, strings in structures which require offset calculations force the
use of a register when performing the offset calculation and therefore
require a second register to dereference the value of the other 8 bytes. In
order to be able to do this, the \texttt{C} field of the \texttt{Item}
structure is being used as it is not needed for other purposes outside
conditionals.

\section{The generation of conditional expressions}
Lorem ipsum dolor sit amet...
=======================================
--- /docs/latex/gogo.toc Sat Jun 26 06:17:59 2010
+++ /docs/latex/gogo.toc Sat Jun 26 09:43:06 2010
@@ -21,15 +21,15 @@
\contentsline {section}{\numberline {7.2}Register
allocation}{13}{section.7.2}
\contentsline {section}{\numberline {7.3}The generation of arithmetical
expressions}{14}{section.7.3}
\contentsline {section}{\numberline {7.4}The generation of
assignments}{14}{section.7.4}
-\contentsline {section}{\numberline {7.5}The generation of conditional
expressions}{14}{section.7.5}
-\contentsline {section}{\numberline {7.6}The generation of
loops}{14}{section.7.6}
-\contentsline {section}{\numberline {7.7}The generation of
functions}{14}{section.7.7}
-\contentsline {section}{\numberline {7.8}Global variable
initialization}{14}{section.7.8}
-\contentsline {section}{\numberline {7.9}String constants}{15}{section.7.9}
-\contentsline {chapter}{\numberline {8}Library and run time}{16}{chapter.8}
-\contentsline {section}{\numberline {8.1}I/O syscalls}{16}{section.8.1}
-\contentsline {section}{\numberline {8.2}The memory
manager}{16}{section.8.2}
-\contentsline {section}{\numberline {8.3}String memory
management}{17}{section.8.3}
-\contentsline {section}{\numberline {8.4}Program parameter
determination}{17}{section.8.4}
-\contentsline {chapter}{\numberline {9}Building}{19}{chapter.9}
-\contentsline {chapter}{\numberline {10}Testing}{20}{chapter.10}
+\contentsline {section}{\numberline {7.5}The generation of conditional
expressions}{15}{section.7.5}
+\contentsline {section}{\numberline {7.6}The generation of
loops}{15}{section.7.6}
+\contentsline {section}{\numberline {7.7}The generation of
functions}{15}{section.7.7}
+\contentsline {section}{\numberline {7.8}Global variable
initialization}{15}{section.7.8}
+\contentsline {section}{\numberline {7.9}String constants}{16}{section.7.9}
+\contentsline {chapter}{\numberline {8}Library and run time}{17}{chapter.8}
+\contentsline {section}{\numberline {8.1}I/O syscalls}{17}{section.8.1}
+\contentsline {section}{\numberline {8.2}The memory
manager}{17}{section.8.2}
+\contentsline {section}{\numberline {8.3}String memory
management}{18}{section.8.3}
+\contentsline {section}{\numberline {8.4}Program parameter
determination}{18}{section.8.4}
+\contentsline {chapter}{\numberline {9}Building}{20}{chapter.9}
+\contentsline {chapter}{\numberline {10}Testing}{21}{chapter.10}

Reply all
Reply to author
Forward
0 new messages