added top element size computation information
This commit is contained in:
parent
5c85d84228
commit
6dc5c01551
3 changed files with 114 additions and 47 deletions
|
@ -49,7 +49,7 @@ occam.X:
|
||||||
cd occam; make "PIC="$(PIC) "TBL="$(TBL) "EQN="$(EQN) "TARGET="$(TARGET)
|
cd occam; make "PIC="$(PIC) "TBL="$(TBL) "EQN="$(EQN) "TARGET="$(TARGET)
|
||||||
ego.doc: ego.X
|
ego.doc: ego.X
|
||||||
ego.X:
|
ego.X:
|
||||||
cd ego; make "REFER="$(REFER) "TARGET="$(TARGET)
|
cd ego; make "REFER="$(REFER) "TARGET="$(TARGET) "TBL="$(TBL)
|
||||||
em.$(SUF): em.X
|
em.$(SUF): em.X
|
||||||
em.X:
|
em.X:
|
||||||
cd em; make "TBL="$(TBL) "NROFF="$(NROFF) "SUF="$(SUF) "TARGET="$(TARGET)
|
cd em; make "TBL="$(TBL) "NROFF="$(NROFF) "SUF="$(SUF) "TARGET="$(TARGET)
|
||||||
|
|
|
@ -13,7 +13,7 @@ Vrije Universiteit
|
||||||
Amsterdam, The Netherlands
|
Amsterdam, The Netherlands
|
||||||
.PP
|
.PP
|
||||||
This document specifies the implementation-defined behaviour of the ANSI-C
|
This document specifies the implementation-defined behaviour of the ANSI-C
|
||||||
front end of the Amsterdam Compiler Kit as required by ANS X3.159-1989. Since
|
front end of the Amsterdam Compiler Kit as required by ANS X3.159-1989. Since
|
||||||
the implementation-defined behaviour sometimes depends on the machine
|
the implementation-defined behaviour sometimes depends on the machine
|
||||||
compiling on or for, some items will be left unspecified in this
|
compiling on or for, some items will be left unspecified in this
|
||||||
document\(dg.
|
document\(dg.
|
||||||
|
@ -24,7 +24,7 @@ compile-time behaviour
|
||||||
The compiler assumes that it runs on a UNIX system.
|
The compiler assumes that it runs on a UNIX system.
|
||||||
.NS A.6.3.1
|
.NS A.6.3.1
|
||||||
.IP -
|
.IP -
|
||||||
Diagnostics are placed on the standard error output. They have the
|
Diagnostics are placed on the standard error output. They have the
|
||||||
following specification:
|
following specification:
|
||||||
.br
|
.br
|
||||||
"<file>", line <nr>: [(<class>)] <diagnostic>
|
"<file>", line <nr>: [(<class>)] <diagnostic>
|
||||||
|
@ -33,21 +33,21 @@ There are three classes of diagnostics: "error", "strict" and "warning".
|
||||||
When the class is "error", the <class> is absent.
|
When the class is "error", the <class> is absent.
|
||||||
.br
|
.br
|
||||||
The class "strict" is used for violations of the standard which are
|
The class "strict" is used for violations of the standard which are
|
||||||
not severe enough to stop compilation. An example is the the occurrence
|
not severe enough to stop compilation. An example is the the occurrence
|
||||||
of non white-space after an '#else' or '#endif' pre-processing
|
of non white-space after an '#else' or '#endif' pre-processing
|
||||||
directive. The class "warning" is used for legal but dubious
|
directive. The class "warning" is used for legal but dubious
|
||||||
constructions. An example is overflow of constant expressions.
|
constructions. An example is overflow of constant expressions.
|
||||||
.NS A.6.3.2
|
.NS A.6.3.2
|
||||||
.IP -
|
.IP -
|
||||||
The function 'main' can have two arguments. The first argument is an
|
The function 'main' can have two arguments. The first argument is an
|
||||||
integer specifying the number of arguments on the command line. The second
|
integer specifying the number of arguments on the command line. The second
|
||||||
argument is a pointer to an array of pointers to the arguments (as
|
argument is a pointer to an array of pointers to the arguments (as
|
||||||
strings).
|
strings).
|
||||||
.IP -
|
.IP -
|
||||||
Interactive devices are terminals.
|
Interactive devices are terminals.
|
||||||
.NS A.6.3.3
|
.NS A.6.3.3
|
||||||
.IP -
|
.IP -
|
||||||
The number of significant characters is an option. By default it is 64.
|
The number of significant characters is an option. By default it is 64.
|
||||||
There is a distinction between upper and lower case.
|
There is a distinction between upper and lower case.
|
||||||
.NS A.6.3.4
|
.NS A.6.3.4
|
||||||
.IP -
|
.IP -
|
||||||
|
@ -70,13 +70,13 @@ A plain 'char' has the same range of values as 'signed char'.
|
||||||
.NS A.6.3.5
|
.NS A.6.3.5
|
||||||
.IP -
|
.IP -
|
||||||
The compiler assumes that it works on and compiles for a
|
The compiler assumes that it works on and compiles for a
|
||||||
2-complement binary-number system. Shorts will use 2 bytes and longs
|
2-complement binary-number system. Shorts will use 2 bytes and longs
|
||||||
will use 4 bytes. The size of integers are machine dependent.
|
will use 4 bytes. The size of integers are machine dependent.
|
||||||
.IP -
|
.IP -
|
||||||
Converting an integer to a shorter signed integer is implemented by
|
Converting an integer to a shorter signed integer is implemented by
|
||||||
ignoring the high-order byte(s) of the former.
|
ignoring the high-order byte(s) of the former.
|
||||||
Converting a unsigned integer to a signed integer of the same type is
|
Converting a unsigned integer to a signed integer of the same type is
|
||||||
only done in administration. This means that the bit-pattern remains
|
only done in administration. This means that the bit-pattern remains
|
||||||
unchanged.
|
unchanged.
|
||||||
.IP -
|
.IP -
|
||||||
The result of bitwise operations on signed integers are what can be
|
The result of bitwise operations on signed integers are what can be
|
||||||
|
@ -98,45 +98,45 @@ Truncation is always to the nearest floating-point number that can
|
||||||
be represented.
|
be represented.
|
||||||
.NS A.6.3.7
|
.NS A.6.3.7
|
||||||
.IP -
|
.IP -
|
||||||
The type returned by the sizeof-operator is 'unsigned int'. This is done
|
The type returned by the sizeof-operator (also known as size_t)
|
||||||
for backward compatibility reasons.
|
is 'unsigned int'. This is done for backward compatibility reasons.
|
||||||
.IP -
|
.IP -
|
||||||
Casting an integer to a pointer or vice versa has no effect in
|
Casting an integer to a pointer or vice versa has no effect in
|
||||||
bit-pattern when the sizes are equal. Otherwise the value will be
|
bit-pattern when the sizes are equal. Otherwise the value will be
|
||||||
truncated or zero-extended (depending on the direction of the
|
truncated or zero-extended (depending on the direction of the
|
||||||
conversion and the relative sizes).
|
conversion and the relative sizes).
|
||||||
.IP -
|
.IP -
|
||||||
When a pointer is as large as an integer, the type of a 'ptrdiff_t' will
|
When a pointer is as large as an integer, the type of a 'ptrdiff_t' will
|
||||||
be 'int'. Otherwise the type will be 'long'.
|
be 'int'. Otherwise the type will be 'long'.
|
||||||
.NS A.6.3.8
|
.NS A.6.3.8
|
||||||
.IP -
|
.IP -
|
||||||
Since the front end has only limited control over the registers, it can
|
Since the front end has only limited control over the registers, it can
|
||||||
only make it more likely that variables that are declared as
|
only make it more likely that variables that are declared as
|
||||||
registers also end up in registers. The only things that can possibly be
|
registers also end up in registers. The only things that can possibly be
|
||||||
put into registers are : 'int', 'long', 'float', 'double', 'long double'
|
put into registers are : 'int', 'long', 'float', 'double', 'long double'
|
||||||
and pointers.
|
and pointers.
|
||||||
.NS A.6.3.9
|
.NS A.6.3.9
|
||||||
.IP -
|
.IP -
|
||||||
When a member of a union object is accessed using a member of a
|
When a member of a union object is accessed using a member of a
|
||||||
different type, the resulting value will usually be garbage. The
|
different type, the resulting value will usually be garbage. The
|
||||||
compiler makes no effort to catch these errors.
|
compiler makes no effort to catch these errors.
|
||||||
.IP -
|
.IP -
|
||||||
The alignment of types is a compile-time option. The alignment of
|
The alignment of types is a compile-time option. The alignment of
|
||||||
a structure-member is the alignment of its type. Usually, the
|
a structure-member is the alignment of its type. Usually, the
|
||||||
alignment is passed on to the compiler by the 'ack' program. When a
|
alignment is passed on to the compiler by the 'ack' program. When a
|
||||||
user wants to do this manually, he/she should be prepared for trouble.
|
user wants to do this manually, he/she should be prepared for trouble.
|
||||||
.IP -
|
.IP -
|
||||||
A "plain" 'int' bit-field is taken as a 'signed int'. This means that
|
A "plain" 'int' bit-field is taken as a 'signed int'. This means that
|
||||||
a field with a size 1 bit can only store the values 0 and -1.
|
a field with a size 1 bit can only store the values 0 and -1.
|
||||||
.IP -
|
.IP -
|
||||||
The order of allocation of bit-fields is a compile-time option. By
|
The order of allocation of bit-fields is a compile-time option. By
|
||||||
default, high-order bits are allocated first.
|
default, high-order bits are allocated first.
|
||||||
.IP -
|
.IP -
|
||||||
An enum has the same size as a "plain" 'int'.
|
An enum has the same size as a "plain" 'int'.
|
||||||
.NS A.6.3.10
|
.NS A.6.3.10
|
||||||
.IP -
|
.IP -
|
||||||
An access to a volatile declared variable is done by just mentioning
|
An access to a volatile declared variable is done by just mentioning
|
||||||
the variable. E.g. the statement "x;" where x is declared volatile,
|
the variable. E.g. the statement "x;" where x is declared volatile,
|
||||||
constitutes an access.
|
constitutes an access.
|
||||||
.S A.6.3.11
|
.S A.6.3.11
|
||||||
.IP -
|
.IP -
|
||||||
|
@ -153,10 +153,10 @@ Since both the pre-processor and the compiler assume ASCII-characters,
|
||||||
a single character constant in a conditional-inclusion directive
|
a single character constant in a conditional-inclusion directive
|
||||||
matches the same value in the execution character set.
|
matches the same value in the execution character set.
|
||||||
.IP -
|
.IP -
|
||||||
The pre-processor recognizes -I... command-line options. The
|
The pre-processor recognizes -I... command-line options. The
|
||||||
directories thus specified are searched first. After that, depending on the
|
directories thus specified are searched first. After that, depending on the
|
||||||
command that the preprocessor is called with, machine/system-dependant
|
command that the preprocessor is called with, machine/system-dependant
|
||||||
directories are searched. After that, ~em/include/_tail_ac and
|
directories are searched. After that, ~em/include/_tail_ac and
|
||||||
/usr/include are visited.
|
/usr/include are visited.
|
||||||
.IP -
|
.IP -
|
||||||
Quoted names are first looked for in the directory in which the file
|
Quoted names are first looked for in the directory in which the file
|
||||||
|
@ -171,7 +171,7 @@ Since the compiler runs on UNIX, __DATE__ and __TIME__ will always be
|
||||||
defined.
|
defined.
|
||||||
.NS A.6.3.14
|
.NS A.6.3.14
|
||||||
.IP -
|
.IP -
|
||||||
NULL is defined as ((void *)0). This in order to flag dubious
|
NULL is defined as ((void *)0). This in order to flag dubious
|
||||||
constructions like "int x = NULL;".
|
constructions like "int x = NULL;".
|
||||||
.IP -
|
.IP -
|
||||||
The diagnostic printed by 'assert' is as follows:
|
The diagnostic printed by 'assert' is as follows:
|
||||||
|
@ -195,7 +195,7 @@ isprint() <space>-~ (== \e040-\e176)
|
||||||
.TE
|
.TE
|
||||||
.KE
|
.KE
|
||||||
As an addition, there is an isascii() macro, which tests whether a character
|
As an addition, there is an isascii() macro, which tests whether a character
|
||||||
is an ascii character. Characters in the range from \e000 to \e177 are ascii
|
is an ascii character. Characters in the range from \e000 to \e177 are ascii
|
||||||
characters.
|
characters.
|
||||||
.KS
|
.KS
|
||||||
.IP -
|
.IP -
|
||||||
|
@ -221,9 +221,9 @@ The function fmod() returns 0.0 and sets errno to EDOM when the second
|
||||||
argument is 0.0.
|
argument is 0.0.
|
||||||
.IP -
|
.IP -
|
||||||
The set of signals for the signal() function depends on the UNIX-system
|
The set of signals for the signal() function depends on the UNIX-system
|
||||||
which the compiler is compiling for. The default handling, semantics
|
which the compiler is compiling for. The default handling, semantics
|
||||||
and behaviour of these signals are those specified by the operating
|
and behaviour of these signals are those specified by the operating
|
||||||
system vendor. The default handling is not reset when SIGILL is
|
system vendor. The default handling is not reset when SIGILL is
|
||||||
received.
|
received.
|
||||||
.IP -
|
.IP -
|
||||||
A text-stream need not end in a new-line character.
|
A text-stream need not end in a new-line character.
|
||||||
|
@ -249,11 +249,11 @@ the '/'.
|
||||||
A file can be open multiple times.
|
A file can be open multiple times.
|
||||||
.IP -
|
.IP -
|
||||||
When a remove() is done on an open file, reading and writing behave
|
When a remove() is done on an open file, reading and writing behave
|
||||||
just as can be expected from a non-removed file. When the associated
|
just as can be expected from a non-removed file. When the associated
|
||||||
stream is closed, all written data will be lost.
|
stream is closed, all written data will be lost.
|
||||||
.IP -
|
.IP -
|
||||||
When a file exists prior to a call to rename(), the behaviour is that
|
When a file exists prior to a call to rename(), the behaviour is that
|
||||||
of the underlying UNIX system. Normally, the call would fail.
|
of the underlying UNIX system. Normally, the call would fail.
|
||||||
.IP -
|
.IP -
|
||||||
The %p conversion in fprintf() has the same effect as %#x or %#lx,
|
The %p conversion in fprintf() has the same effect as %#x or %#lx,
|
||||||
depending on the sizes of pointer and integer.
|
depending on the sizes of pointer and integer.
|
||||||
|
@ -262,7 +262,7 @@ The %p conversion in fscanf() has the same effect as %x or %lx,
|
||||||
depending on the sizes of pointer and integer.
|
depending on the sizes of pointer and integer.
|
||||||
.IP -
|
.IP -
|
||||||
A - character that is neither the first nor the last character in the
|
A - character that is neither the first nor the last character in the
|
||||||
scanlist for %[ conversion is taken to be a range indicator. When the
|
scanlist for %[ conversion is taken to be a range indicator. When the
|
||||||
first character has a higher ASCII-value than the second, the - will
|
first character has a higher ASCII-value than the second, the - will
|
||||||
just be put into the scanlist.
|
just be put into the scanlist.
|
||||||
.IP -
|
.IP -
|
||||||
|
@ -284,7 +284,7 @@ The mapping of errors to strings is done by strerror().
|
||||||
When the requested size is zero, malloc(), calloc() and realloc()
|
When the requested size is zero, malloc(), calloc() and realloc()
|
||||||
return a null-pointer.
|
return a null-pointer.
|
||||||
.IP -
|
.IP -
|
||||||
When abort() is called, output buffers will be flushed. Temporary files
|
When abort() is called, output buffers will be flushed. Temporary files
|
||||||
(made with the tmpfile() function) will have disappeared when SIGABRT
|
(made with the tmpfile() function) will have disappeared when SIGABRT
|
||||||
is not caught or ignored.
|
is not caught or ignored.
|
||||||
.IP -
|
.IP -
|
||||||
|
@ -300,7 +300,7 @@ putenv("TERM=a230");
|
||||||
.br
|
.br
|
||||||
The argument to putenv() is stored in an internal table, so malloc'ed
|
The argument to putenv() is stored in an internal table, so malloc'ed
|
||||||
strings can not be freed until another call to putenv() (which sets the
|
strings can not be freed until another call to putenv() (which sets the
|
||||||
same environment variable) is made. The function returns 1 if it fails,
|
same environment variable) is made. The function returns 1 if it fails,
|
||||||
0 otherwise.
|
0 otherwise.
|
||||||
.LP
|
.LP
|
||||||
.IP -
|
.IP -
|
||||||
|
@ -349,7 +349,7 @@ ERANGE "Result too large"
|
||||||
.TE
|
.TE
|
||||||
everything else causes strerror() to return "unknown error"
|
everything else causes strerror() to return "unknown error"
|
||||||
.IP -
|
.IP -
|
||||||
The local time zone is per default MET (GMT + 1:00:00). This can be
|
The local time zone is per default MET (GMT + 1:00:00). This can be
|
||||||
changed through the TZ environment variable, or by some changes in the
|
changed through the TZ environment variable, or by some changes in the
|
||||||
sources.
|
sources.
|
||||||
.IP -
|
.IP -
|
||||||
|
|
87
doc/ncg.doc
87
doc/ncg.doc
|
@ -301,16 +301,17 @@ Here is a list of reserved words; all of these are unavailable as identifiers.
|
||||||
.TS
|
.TS
|
||||||
box;
|
box;
|
||||||
l l l l l.
|
l l l l l.
|
||||||
ADDR STACK from proc sfit
|
ADDR STACKINGRULES gen proc test
|
||||||
COERCIONS STACKINGRULES gen reg_any test
|
COERCIONS TESTS highw reg_any to
|
||||||
INSTRUCTIONS TESTS highw reg_float to
|
INSTRUCTIONS TIMEFACTOR inreg reg_float topeltsize
|
||||||
INT TIMEFACTOR inreg reg_loop ufit
|
INT TOKENS is_rom reg_loop ufit
|
||||||
MOVES TOKENS is_rom reg_pointer uses
|
MOVES call kills reg_pointer uses
|
||||||
PATTERNS call kills regvar with
|
PATTERNS cost lab regvar with
|
||||||
PROPERTIES cost leaving return yields
|
PROPERTIES defined labeldef return yields
|
||||||
REGISTERS defined loww reusing
|
REGISTERS exact leaving reusing
|
||||||
SETS exact move rom
|
SETS example loww rom
|
||||||
SIZEFACTOR example pat samesign
|
SIZEFACTOR fallthrough move samesign
|
||||||
|
STACK from pat sfit
|
||||||
.TE
|
.TE
|
||||||
C style comments are accepted.
|
C style comments are accepted.
|
||||||
.DS
|
.DS
|
||||||
|
@ -928,6 +929,17 @@ If
|
||||||
.I t
|
.I t
|
||||||
is omitted reg_any is assumed.
|
is omitted reg_any is assumed.
|
||||||
Undefined if inreg(\fIe\fP)<=0 .
|
Undefined if inreg(\fIe\fP)<=0 .
|
||||||
|
.LP
|
||||||
|
The next two `functions' are only needed in a table that
|
||||||
|
uses the top element size information.
|
||||||
|
.IP topeltsize($a) 16
|
||||||
|
Returns the size of the element on top of the EM-stack at the label
|
||||||
|
identified by $a. This can be used to put the top of the stack in a
|
||||||
|
register at the moment of an unconditional jump. At an unconditional jump,
|
||||||
|
the size of the top-element will always look 0.
|
||||||
|
.IP fallthrough($a)
|
||||||
|
Returns 1 if the label identified by $a can be reached via fallthrough, 0
|
||||||
|
otherwise.
|
||||||
.NH 2
|
.NH 2
|
||||||
Token descriptions
|
Token descriptions
|
||||||
.PP
|
.PP
|
||||||
|
@ -1017,6 +1029,13 @@ This rule of three is an unfortunate implementation dependent restriction,
|
||||||
but patterns longer than three EM instructions are luckily not needed
|
but patterns longer than three EM instructions are luckily not needed
|
||||||
too often.
|
too often.
|
||||||
.PP
|
.PP
|
||||||
|
The EM mnemonic may also be the pseudo-instruction \fBlab\fP, which matches
|
||||||
|
a label. Its argument can be used in testing on topeltsize and
|
||||||
|
fallthrough. When this pattern is specified, the label should be defined
|
||||||
|
explicitly with a
|
||||||
|
.I labeldef
|
||||||
|
statement.
|
||||||
|
.PP
|
||||||
Following the EM-pattern there may be more than one code
|
Following the EM-pattern there may be more than one code
|
||||||
rule,
|
rule,
|
||||||
.I cg
|
.I cg
|
||||||
|
@ -1308,6 +1327,16 @@ C-routine
|
||||||
Explanation of this must wait for the description of the
|
Explanation of this must wait for the description of the
|
||||||
file mach.c below.
|
file mach.c below.
|
||||||
.IP 5)
|
.IP 5)
|
||||||
|
The
|
||||||
|
.I labeldef
|
||||||
|
statement. Its only argument should be that of the
|
||||||
|
.I lab
|
||||||
|
pseudo-instruction. This is needed to generate local labels when the
|
||||||
|
top element size information is used. It takes the form
|
||||||
|
.DS
|
||||||
|
labeldef $i
|
||||||
|
.DE
|
||||||
|
.IP 6)
|
||||||
A temporary label of the form <digit>: may be placed here.
|
A temporary label of the form <digit>: may be placed here.
|
||||||
Expressions of the form [0-9][bf] in this code rule
|
Expressions of the form [0-9][bf] in this code rule
|
||||||
generate the same string as is used for this label.
|
generate the same string as is used for this label.
|
||||||
|
@ -1552,6 +1581,35 @@ A simple jump.
|
||||||
The stack pattern guarantees that everything will be stacked
|
The stack pattern guarantees that everything will be stacked
|
||||||
before the jump is taken.
|
before the jump is taken.
|
||||||
.DS
|
.DS
|
||||||
|
pat lab topeltsize($1)==2 && !fallthrough($1)
|
||||||
|
gen labeldef $1 yields r0
|
||||||
|
|
||||||
|
pat lab topeltsize($1)==2 && fallthrough($1)
|
||||||
|
with src2
|
||||||
|
gen move %1,r0
|
||||||
|
labeldef $1 yields r0
|
||||||
|
|
||||||
|
pat lab topeltsize($1)!=2
|
||||||
|
with STACK
|
||||||
|
kills all
|
||||||
|
gen labeldef $1
|
||||||
|
|
||||||
|
pat bra topeltsize($1)==2
|
||||||
|
with src2 STACK
|
||||||
|
gen move %1,d0
|
||||||
|
jbr {label, $1}
|
||||||
|
|
||||||
|
pat bra topeltsize($1)!=2
|
||||||
|
with STACK
|
||||||
|
gen jbr {label, $1}
|
||||||
|
.DE
|
||||||
|
The combination of these patterns make sure that the top of the EM-stack will
|
||||||
|
be in register r0 whenever necessary. The top element size mechanism will
|
||||||
|
also show a size of 0 whenever a conditional branch to a label
|
||||||
|
occurs. This saves a lot of patterns and hardly decreases performance.
|
||||||
|
When the same register is used to return function results, this can save
|
||||||
|
many moves to and from the stack.
|
||||||
|
.DS
|
||||||
.ta 7.5c
|
.ta 7.5c
|
||||||
pat cal
|
pat cal
|
||||||
with STACK
|
with STACK
|
||||||
|
@ -2738,6 +2796,11 @@ DO_RETURN
|
||||||
Returns from this level of codegen().
|
Returns from this level of codegen().
|
||||||
Is used at the end of coercions,
|
Is used at the end of coercions,
|
||||||
move rules etc..
|
move rules etc..
|
||||||
|
.NH 4
|
||||||
|
DO_LABDEF
|
||||||
|
.PP
|
||||||
|
This prints a label when the top element size mechanism is used. Only done on
|
||||||
|
toplevel.
|
||||||
.NH 3
|
.NH 3
|
||||||
compute.c
|
compute.c
|
||||||
.PP
|
.PP
|
||||||
|
@ -2803,6 +2866,10 @@ This module maintains a list of global symbols that have a
|
||||||
pseudo associated.
|
pseudo associated.
|
||||||
There are functions to enter a symbol and to find a symbol.
|
There are functions to enter a symbol and to find a symbol.
|
||||||
.NH 3
|
.NH 3
|
||||||
|
label.c
|
||||||
|
.PP
|
||||||
|
This module contains routines to handle the top element size messages.
|
||||||
|
.NH 3
|
||||||
main.c
|
main.c
|
||||||
.PP
|
.PP
|
||||||
Main routine of the code generator.
|
Main routine of the code generator.
|
||||||
|
|
Loading…
Reference in a new issue