[gogc] 2 new revisions pushed by bytbox on 2010-08-17 22:51 GMT

0 views
Skip to first unread message

go...@googlecode.com

unread,
Aug 17, 2010, 10:01:58 PM8/17/10
to go...@googlegroups.com
2 new revisions:

Revision: fbc2ae874a
Author: Andreas Unterweger <and...@gmx.at>
Date: Wed Jun 16 21:59:49 2010
Log: testing: Ack.ed new symbol table format
http://code.google.com/p/gogc/source/detail?r=fbc2ae874a

Revision: 267a778495
Author: Andreas Unterweger <and...@gmx.at>
Date: Wed Jun 16 23:53:02 2010
Log: doc: Some more documentation
http://code.google.com/p/gogc/source/detail?r=267a778495

==============================================================================
Revision: fbc2ae874a
Author: Andreas Unterweger <and...@gmx.at>
Date: Wed Jun 16 21:59:49 2010
Log: testing: Ack.ed new symbol table format
http://code.google.com/p/gogc/source/detail?r=fbc2ae874a

Modified:
/testing/checksums
/testing/results/_gogo_.sog

=======================================
--- /testing/checksums Tue Jun 15 11:56:44 2010
+++ /testing/checksums Wed Jun 16 21:59:49 2010
@@ -17,5 +17,5 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
tmp/2010-05-09_struct8_fail.go
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
tmp/2010-05-09_struct9.go
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
tmp/2010-05-09_symtable_fail.go
-651b7077e5697559b0a200c0d7253d775e9143be1da8585c94bdd1609f630d5f
tmp/_gogo_.sog
+d99214d3aca787c37da4568c34231dff59aa2a0198a8568967c897ffff7d3385
tmp/_gogo_.sog
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
tmp/test.go
=======================================
--- /testing/results/_gogo_.sog Tue Jun 15 11:56:44 2010
+++ /testing/results/_gogo_.sog Wed Jun 16 21:59:49 2010
@@ -9,25 +9,27 @@
// This code is automatically generated. DO NOT EDIT IT!
//

+__UNLINKED_CODE
//Symbol table:
-//TYPE,·uint64,8,8
-//TYPE,·byte,1,8
-//TYPE,·string,16,16
-//TYPE,·bool,8,8
-//TYPE,main·foo,32,32
-//TYPE,main·test,360,360
-//FUNC,0,main·init,
-//FUNC,0,main·test,bla:uint64,blub:string
-//FUNC,0,main·foo,return value:uint64
-//FUNC,0,main·bar,a:uint64,return value:uint64
-//FUNC,0,main·foobar,a:uint64,b:uint64,c:uint64,return value:uint64
-//FUNC,0,main·bazz,a:uint64,return value:uint64
-//FUNC,0,main·blub,r:string,return value:string
-//FUNC,0,main·main,
-//FUNC,0,main·bazz_fwd,b:byte,return value:uint64
-//FUNC,0,main·foo_fwd,
-//FUNC,0,main·muh,
-//FUNC,0,main·maeh,y:string,z:string,return value:string
+//TYPE,0,·uint64,8,8
+//TYPE,0,·byte,1,8
+//TYPE,0,·string,16,16
+//TYPE,0,·bool,8,8
+//TYPE,0,main·foo,32,32
+//TYPE,0,main·test,360,360
+//FUNC,0,main·init
+//FUNC,0,main·test,bla:·uint64,blub:·string
+//FUNC,0,main·foo,return value:·uint64
+//FUNC,0,main·bar,a:·uint64,return value:·uint64
+//FUNC,0,main·foobar,a:·uint64,b:·uint64,c:·uint64,return value:·uint64
+//FUNC,0,main·bazz,a:·uint64,return value:·uint64
+//FUNC,0,main·blub,r:·string,return value:·string
+//FUNC,0,main·main
+//FUNC,0,main·bazz_fwd,b:·byte,return value:·uint64
+//FUNC,0,main·foo_fwd
+//FUNC,0,main·muh
+//FUNC,0,main·maeh,y:·string,z:·string,return value:·string
+//End Symbol table

//--- String buffer start ('Test') at tests/test.go:24:26
DATA data+712(SB)/1, $84

==============================================================================
Revision: 267a778495
Author: Andreas Unterweger <and...@gmx.at>
Date: Wed Jun 16 23:53:02 2010
Log: doc: Some more documentation
http://code.google.com/p/gogc/source/detail?r=267a778495

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 Wed Jun 9 09:43:02 2010
+++ /docs/latex/gogo.aux Wed Jun 16 23:53:02 2010
@@ -54,46 +54,48 @@
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{lol}{\addvspace {10\p@ }}
+\citation{wir96}
\@writefile{toc}{\contentsline {chapter}{\numberline {6}Symbol
table}{10}{chapter.6}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{lol}{\addvspace {10\p@ }}
-\@writefile{toc}{\contentsline {section}{\numberline {6.1}Supported data
types}{10}{section.6.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {6.2}Local variables
and offset calculations}{10}{section.6.2}}
+\@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}The code
generator}{11}{chapter.7}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {7}Code
generation}{12}{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}{11}{section.7.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.2}Register
allocation}{11}{section.7.2}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.3}The generation
of arithmetical expressions}{11}{section.7.3}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.4}The generation
of assignments}{11}{section.7.4}}
-\@writefile{toc}{\contentsline {subsection}{\numberline {7.4.1}The
generation of conditional expressions}{11}{subsection.7.4.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.5}The generation
of loops}{11}{section.7.5}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.6}The generation
of functions}{12}{section.7.6}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.7}Global variable
initialization}{12}{section.7.7}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.8}String
constants}{12}{section.7.8}}
+\@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}{}}
\citation{var08}
\citation{var10}
\citation{var97}
\citation{var97}
-\@writefile{toc}{\contentsline {chapter}{\numberline {8}Library and run
time}{13}{chapter.8}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {8}Library and run
time}{14}{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}{13}{section.8.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {8.2}The memory
manager}{13}{section.8.2}}
+\@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}}
\citation{var06}
-\@writefile{toc}{\contentsline {section}{\numberline {8.3}String memory
management}{14}{section.8.3}}
-\@writefile{toc}{\contentsline {section}{\numberline {8.4}Program
parameter determination}{14}{section.8.4}}
-\@writefile{toc}{\contentsline {chapter}{\numberline
{9}Building}{16}{chapter.9}}
+\@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{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}{17}{chapter.10}}
+\@writefile{toc}{\contentsline {chapter}{\numberline
{10}Testing}{18}{chapter.10}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{lol}{\addvspace {10\p@ }}
=======================================
--- /docs/latex/gogo.log Wed Jun 9 09:43:02 2010
+++ /docs/latex/gogo.log Wed Jun 16 23:53:02 2010
@@ -1,4 +1,4 @@
-This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
(format=pdflatex 2010.6.7) 9 JUN 2010 18:41
+This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
(format=pdflatex 2010.6.7) 17 JUN 2010 08:51
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
@@ -424,39 +424,76 @@

]
Chapter 6.
+
+Underfull \hbox (badness 10000) in paragraph at lines 155--183
+
+ []
+
+
+Underfull \hbox (badness 10000) in paragraph at lines 155--183
+
+ []
+
+
+Overfull \hbox (66.35977pt too wide) in paragraph at lines 155--183
+[]
+ []
+
+
+Underfull \hbox (badness 10000) in paragraph at lines 155--183
+
+ []
+
[10

]
+Underfull \hbox (badness 10000) in paragraph at lines 185--194
+
+ []
+
+
+Overfull \hbox (4.06653pt too wide) in paragraph at lines 185--194
+[]
+ []
+
+[11]
Chapter 7.
-[11
-
-] [12]
+[12
+
+] [13]
Chapter 8.
-[13
-
-] [14] [15]
+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
+
+ []
+
+[14
+
+] [15] [16]
Chapter 9.
-[16
+[17

]
Chapter 10.

-Underfull \hbox (badness 10000) in paragraph at lines 231--233
+Underfull \hbox (badness 10000) in paragraph at lines 265--267

[]

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
234.
-(./gogo.bbl [17
-
-]) [18
+(Font) Font shape `OMS/cmsy/m/n' tried instead on input line
268.
+(./gogo.bbl [18
+
+]) [19

] (./gogo.aux) )
Here is how much of TeX's memory you used:
- 7387 strings out of 495061
- 107248 string characters out of 1182622
- 238036 words of memory out of 3000000
- 10349 multiletter control sequences out of 15000+50000
+ 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
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
@@ -468,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 (18 pages, 172091 bytes).
+Output written on gogo.pdf (19 pages, 180616 bytes).
PDF statistics:
- 382 PDF objects out of 1000 (max. 8388607)
- 132 named destinations out of 1000 (max. 500000)
+ 390 PDF objects out of 1000 (max. 8388607)
+ 133 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 9 09:43:02 2010
+++ /docs/latex/gogo.out Wed Jun 16 23:53:02 2010
@@ -8,7 +8,7 @@
\BOOKMARK [0][-]{chapter.6}{Symbol table}{}
\BOOKMARK [1][-]{section.6.1}{Supported data types}{chapter.6}
\BOOKMARK [1][-]{section.6.2}{Local variables and offset
calculations}{chapter.6}
-\BOOKMARK [0][-]{chapter.7}{The code generator}{}
+\BOOKMARK [0][-]{chapter.7}{Code generation}{}
\BOOKMARK [1][-]{section.7.1}{Assembly output}{chapter.7}
\BOOKMARK [1][-]{section.7.2}{Register allocation}{chapter.7}
\BOOKMARK [1][-]{section.7.3}{The generation of arithmetical
expressions}{chapter.7}
=======================================
--- /docs/latex/gogo.pdf Wed Jun 9 09:43:02 2010
+++ /docs/latex/gogo.pdf Wed Jun 16 23:53:02 2010
Binary file, no diff available.
=======================================
--- /docs/latex/gogo.tex Wed Jun 9 09:43:02 2010
+++ /docs/latex/gogo.tex Wed Jun 16 23:53:02 2010
@@ -152,15 +152,50 @@
Lorem ipsum dolor sit amet...

\chapter{Symbol table}
- Lorem ipsum dolor sit amet...
-
+ In order to be able to lookup local and global variable names as well
as function names, a symbol table is required. Based on \cite{wir96},
object and type descriptors were used, each containing the information
required for lookup and code generation. Object descriptors are used to
store information about variables and parameters whereas type descriptors
are used to store information about types and functions.\\
+ The following table summarizes the fields of the object and type
descriptors and their respective purpose. Some fields had to be added in
order to support forward declarations and the distinction between values
and pointers.\\ \\
+ \textbf{ObjectDesc:}\\
+ \begin{tabular}{|c|c|l|}
+ \hline
+ \textbf{Field} & \textbf{Type} & \textbf{Purpose}\\ \hline
+ Name & \texttt{string} & The object's name\\ \hline
+ PackageName & \texttt{string} & The object's package (Go name
space)\\ \hline
+ Class & \texttt{uint64} & The descriptors's kind (variable, field,
parameter)\\ \hline
+ ObjType & \texttt{*TypeDesc} & The object's type\\ \hline
+ PtrType & \texttt{uint64} & If 1, the object's type is
\texttt{*ObjType}; if 0, \texttt{ObjType}\\ \hline
+ Next & \texttt{*ObjType} & Next object (linked list)\\ \hline
+ \end{tabular}\\ \\
+ \textbf{TypeDesc:}\\
+ \begin{tabular}{|c|c|l|}
+ \hline
+ \textbf{Field} & \textbf{Type} & \textbf{Purpose}\\ \hline
+ Name & \texttt{string} & The type's/function's name\\ \hline
+ PackageName & \texttt{string} & The type's/function's package (Go
name space)\\ \hline
+ ForwardDecl & \texttt{uint64} & If 1, the type/function has not
yet been fully delcared/implemented\\ \hline
+ Form & \texttt{uint64} & The descriptor's kind (simple type, array
type, struct type, function)\\ \hline
+ Len & \texttt{uint64} & For simple types: type size in bytes, for
arrays: array size\\ \hline
+ Fields & \texttt{*ObjDesc} & For struct types: struct fields, for
functions: function parameters\\ \hline
+ Base & \texttt{*TypeDesc} & For array types: the array base type\\
\hline
+ Next & \texttt{*TypeDesc} & Next type/function (linked list)\\
\hline
+ \end{tabular}\\ \\
+ Both symbol table build-up and lookup is integrated into the parser.
Whenever sufficient information (variable name, function name, type name;
optionally preceeded by a package name) is encountered, a lookup in the
symbol table is issued. Declarations issue new symbol table entries with
the corresponding descriptor properties as described above.\\
+ Forward declarations are currently only supported for type pointers
(as pointers are always 64 bits in size) and functions (as the affected
offsets can be fixed by the linker if necessary). Whenever supported
forward declarations are encountered, a new symbol table entry is created
with \texttt{ForwardDecl} set to 1. Forward declared function can then be
called, although forward declared type pointers cannot be dereferred until
the size of the type they are pointing to is known (\texttt{ForwardDecl} is
0). When forward declared functions are implemented, the corresponding
symbol table entry is modified (\texttt{ForwardDecl} is set to 0) instead
of creating a new one.
+
\section{Supported data types}
- Lorem ipsum dolor sit amet...
+ GoGo supports 4 built-in value types and the declaration of new
struct and array types as well as pointers to value, struct and array
types. The 4 built-in data types are based on the data types supported by
the Go compiler and form a minimal subset of them in order to perform basic
integer and string operations. The following table lists the built-in value
types, together with their purpose and size.\\ \\
+ \begin{tabular}{|c|c|l|}
+ \hline
+ \textbf{Type} & \textbf{Size} & \textbf{Purpose}\\ \hline
+ \texttt{uint64} & 8 bytes (64 bits) & Unsigned integer with the
target platform's register size\\ \hline
+ \texttt{byte} & 1 byte (8 bits) & Single ASCII character or
unsigned 8 bit integer value\\ \hline
+ \texttt{string} & 16 bytes (see \ref{String constants}) &
Character sequences\\ \hline
+ \texttt{bool} & 8 bytes (64 bits) & Internal type used for
comparisions and jumps\\ \hline
+ \end{tabular}

\section{Local variables and offset calculations}
Lorem ipsum dolor sit amet...

- \chapter{The code generator}
+ \chapter{Code generation}
Lorem ipsum dolor sit amet...

\section{Assembly output}
@@ -189,7 +224,7 @@
Besides the compiled functions from the input file, the code
segment contains a function called main.init which performs the
initialization of global variables. In contrast to local variables which
can be initialized directly at point of their declaration, global variables
need to be initialized before any other methods are called, thus requiring
the main.init function.\\
Global variables in general are stored in the data segment, called
\texttt{data} in the output. They are addressed by their corresponding
symbol table offsets relative to the beginning of the data segment. For the
special treatment of string constants, please refer to the next section.

- \section{String constants}
+ \section{String constants} \label{String constants}
Strings in Go are 16 bytes in size, containing an 8 byte address
(pointer) to its character buffer and an 8 byte length (of which only 4
bytes are used). This makes string length calculations unnecessary and also
explains why strings in Go are read-only and have to be reallocated when
being changed.\\
Whenever a string constant is found in the input code, a new byte
array with the string's length is declared and initialized with the
string's characters. Next, another 16 bytes are allocated which represent
the actual string. Using the main.init function as described in the
previous section, the string's length and the previously allocated byte
array address are assigned to the according offsets of the string in the
data segment. When assigning the string constant (or using it as a
parameter), an item representing a data segment variable with the string's
address is used, therefore eliminating the need for any further special
treatment.

@@ -198,17 +233,16 @@

\section{I/O syscalls}
Besides read and write operations to files (and the console),
exiting the program as well as opening and closing files requires the use
of syscalls. On Linux 64 bit operating systems with Intel architecture,
these syscalls can be invoked by the assembly mnemonic \texttt{SYSCALL}
where the register \texttt{RAX} contains the syscall number defining the
syscall, and the registers \texttt{RDI}, \texttt{RSI} and \texttt{RDX}
contain the first, second and third parameter respectively\cite{var08}.\\
- The following table lists the syscalls used by libgogo, together
with the value of \texttt{RAX} representing the syscall number. The latter
were derived from the constants defined in
\texttt{/usr/src/linux-headers-2.6.32-22/arch/x86/include/asm/unistd\_64.h}
of the current Linux kernel source\cite{var10}. The syscall function
prototypes (for semantics and formal parameters) were derived from the
corresponding Linux man pages (see \cite{var97} and others).\\
+ The following table lists the syscalls used by libgogo, together
with the value of \texttt{RAX} representing the syscall number. The latter
were derived from the constants defined in
\texttt{/usr/src/linux-headers-2.6.32-22/arch/x86/include/asm/unistd\_64.h}
of the current Linux kernel source\cite{var10}. The syscall function
prototypes (for semantics and formal parameters) were derived from the
corresponding Linux man pages (see \cite{var97} and others).\\ \\
\begin{tabular}{|c|c|c|}
\hline
- Syscall number (\texttt{RAX}) & Syscall function & Purpose\\ \hline
+ \textbf{Syscall number (\texttt{RAX})} & \textbf{Syscall function}
& \textbf{Purpose}\\ \hline
0 & \texttt{sys\_read} & Reads from a file\\ \hline
1 & \texttt{sys\_write} & Writes to a file\\ \hline
2 & \texttt{sys\_open} & Opens a file\\ \hline
3 & \texttt{sys\_close} & Closes a file\\ \hline
12 & \texttt{sys\_brk} & See next section\\ \hline
60 & \texttt{sys\_exit} & Exits the program\\ \hline
- %\caption{List of syscalls used in libgogo, based on \var{var10}}
\end{tabular}

\section{The memory manager}
@@ -237,4 +271,5 @@

\bibliographystyle{alpha}
\bibliography{gogo}
+
\end{document}
=======================================
--- /docs/latex/gogo.toc Wed Jun 9 09:43:02 2010
+++ /docs/latex/gogo.toc Wed Jun 16 23:53:02 2010
@@ -14,22 +14,22 @@
\contentsline {chapter}{\numberline {4}Scanner}{8}{chapter.4}
\contentsline {chapter}{\numberline {5}Parser}{9}{chapter.5}
\contentsline {chapter}{\numberline {6}Symbol table}{10}{chapter.6}
-\contentsline {section}{\numberline {6.1}Supported data
types}{10}{section.6.1}
-\contentsline {section}{\numberline {6.2}Local variables and offset
calculations}{10}{section.6.2}
-\contentsline {chapter}{\numberline {7}The code generator}{11}{chapter.7}
-\contentsline {section}{\numberline {7.1}Assembly output}{11}{section.7.1}
-\contentsline {section}{\numberline {7.2}Register
allocation}{11}{section.7.2}
-\contentsline {section}{\numberline {7.3}The generation of arithmetical
expressions}{11}{section.7.3}
-\contentsline {section}{\numberline {7.4}The generation of
assignments}{11}{section.7.4}
-\contentsline {subsection}{\numberline {7.4.1}The generation of
conditional expressions}{11}{subsection.7.4.1}
-\contentsline {section}{\numberline {7.5}The generation of
loops}{11}{section.7.5}
-\contentsline {section}{\numberline {7.6}The generation of
functions}{12}{section.7.6}
-\contentsline {section}{\numberline {7.7}Global variable
initialization}{12}{section.7.7}
-\contentsline {section}{\numberline {7.8}String constants}{12}{section.7.8}
-\contentsline {chapter}{\numberline {8}Library and run time}{13}{chapter.8}
-\contentsline {section}{\numberline {8.1}I/O syscalls}{13}{section.8.1}
-\contentsline {section}{\numberline {8.2}The memory
manager}{13}{section.8.2}
-\contentsline {section}{\numberline {8.3}String memory
management}{14}{section.8.3}
-\contentsline {section}{\numberline {8.4}Program parameter
determination}{14}{section.8.4}
-\contentsline {chapter}{\numberline {9}Building}{16}{chapter.9}
-\contentsline {chapter}{\numberline {10}Testing}{17}{chapter.10}
+\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}

go...@googlecode.com

unread,
Aug 17, 2010, 10:06:08 PM8/17/10
to go...@googlegroups.com
2 new revisions:

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.

Reply all
Reply to author
Forward
0 new messages