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)
|
||||
ego.doc: 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.X:
|
||||
cd em; make "TBL="$(TBL) "NROFF="$(NROFF) "SUF="$(SUF) "TARGET="$(TARGET)
|
||||
|
|
|
@ -13,7 +13,7 @@ Vrije Universiteit
|
|||
Amsterdam, The Netherlands
|
||||
.PP
|
||||
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
|
||||
compiling on or for, some items will be left unspecified in this
|
||||
document\(dg.
|
||||
|
@ -24,7 +24,7 @@ compile-time behaviour
|
|||
The compiler assumes that it runs on a UNIX system.
|
||||
.NS A.6.3.1
|
||||
.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:
|
||||
.br
|
||||
"<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.
|
||||
.br
|
||||
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
|
||||
directive. The class "warning" is used for legal but dubious
|
||||
constructions. An example is overflow of constant expressions.
|
||||
directive. The class "warning" is used for legal but dubious
|
||||
constructions. An example is overflow of constant expressions.
|
||||
.NS A.6.3.2
|
||||
.IP -
|
||||
The function 'main' can have two arguments. The first argument is an
|
||||
integer specifying the number of arguments on the command line. The second
|
||||
The function 'main' can have two arguments. The first argument is an
|
||||
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
|
||||
strings).
|
||||
.IP -
|
||||
Interactive devices are terminals.
|
||||
.NS A.6.3.3
|
||||
.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.
|
||||
.NS A.6.3.4
|
||||
.IP -
|
||||
|
@ -70,13 +70,13 @@ A plain 'char' has the same range of values as 'signed char'.
|
|||
.NS A.6.3.5
|
||||
.IP -
|
||||
The compiler assumes that it works on and compiles for a
|
||||
2-complement binary-number system. Shorts will use 2 bytes and longs
|
||||
will use 4 bytes. The size of integers are machine dependent.
|
||||
2-complement binary-number system. Shorts will use 2 bytes and longs
|
||||
will use 4 bytes. The size of integers are machine dependent.
|
||||
.IP -
|
||||
Converting an integer to a shorter signed integer is implemented by
|
||||
ignoring the high-order byte(s) of the former.
|
||||
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.
|
||||
.IP -
|
||||
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.
|
||||
.NS A.6.3.7
|
||||
.IP -
|
||||
The type returned by the sizeof-operator is 'unsigned int'. This is done
|
||||
for backward compatibility reasons.
|
||||
The type returned by the sizeof-operator (also known as size_t)
|
||||
is 'unsigned int'. This is done for backward compatibility reasons.
|
||||
.IP -
|
||||
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
|
||||
conversion and the relative sizes).
|
||||
.IP -
|
||||
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
|
||||
.IP -
|
||||
Since the front end has only limited control over the registers, it can
|
||||
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'
|
||||
and pointers.
|
||||
.NS A.6.3.9
|
||||
.IP -
|
||||
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.
|
||||
.IP -
|
||||
The alignment of types is a compile-time option. The alignment of
|
||||
a structure-member is the alignment of its type. Usually, the
|
||||
alignment is passed on to the compiler by the 'ack' program. When a
|
||||
The alignment of types is a compile-time option. The alignment of
|
||||
a structure-member is the alignment of its type. Usually, the
|
||||
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.
|
||||
.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.
|
||||
.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.
|
||||
.IP -
|
||||
An enum has the same size as a "plain" 'int'.
|
||||
.NS A.6.3.10
|
||||
.IP -
|
||||
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.
|
||||
.S A.6.3.11
|
||||
.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
|
||||
matches the same value in the execution character set.
|
||||
.IP -
|
||||
The pre-processor recognizes -I... command-line options. The
|
||||
directories thus specified are searched first. After that, depending on the
|
||||
The pre-processor recognizes -I... command-line options. The
|
||||
directories thus specified are searched first. After that, depending on the
|
||||
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.
|
||||
.IP -
|
||||
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.
|
||||
.NS A.6.3.14
|
||||
.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;".
|
||||
.IP -
|
||||
The diagnostic printed by 'assert' is as follows:
|
||||
|
@ -195,7 +195,7 @@ isprint() <space>-~ (== \e040-\e176)
|
|||
.TE
|
||||
.KE
|
||||
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.
|
||||
.KS
|
||||
.IP -
|
||||
|
@ -221,9 +221,9 @@ The function fmod() returns 0.0 and sets errno to EDOM when the second
|
|||
argument is 0.0.
|
||||
.IP -
|
||||
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
|
||||
system vendor. The default handling is not reset when SIGILL is
|
||||
system vendor. The default handling is not reset when SIGILL is
|
||||
received.
|
||||
.IP -
|
||||
A text-stream need not end in a new-line character.
|
||||
|
@ -249,11 +249,11 @@ the '/'.
|
|||
A file can be open multiple times.
|
||||
.IP -
|
||||
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.
|
||||
.IP -
|
||||
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 -
|
||||
The %p conversion in fprintf() has the same effect as %#x or %#lx,
|
||||
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.
|
||||
.IP -
|
||||
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
|
||||
just be put into the scanlist.
|
||||
.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()
|
||||
return a null-pointer.
|
||||
.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
|
||||
is not caught or ignored.
|
||||
.IP -
|
||||
|
@ -300,7 +300,7 @@ putenv("TERM=a230");
|
|||
.br
|
||||
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
|
||||
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.
|
||||
.LP
|
||||
.IP -
|
||||
|
@ -349,7 +349,7 @@ ERANGE "Result too large"
|
|||
.TE
|
||||
everything else causes strerror() to return "unknown error"
|
||||
.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
|
||||
sources.
|
||||
.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
|
||||
box;
|
||||
l l l l l.
|
||||
ADDR STACK from proc sfit
|
||||
COERCIONS STACKINGRULES gen reg_any test
|
||||
INSTRUCTIONS TESTS highw reg_float to
|
||||
INT TIMEFACTOR inreg reg_loop ufit
|
||||
MOVES TOKENS is_rom reg_pointer uses
|
||||
PATTERNS call kills regvar with
|
||||
PROPERTIES cost leaving return yields
|
||||
REGISTERS defined loww reusing
|
||||
SETS exact move rom
|
||||
SIZEFACTOR example pat samesign
|
||||
ADDR STACKINGRULES gen proc test
|
||||
COERCIONS TESTS highw reg_any to
|
||||
INSTRUCTIONS TIMEFACTOR inreg reg_float topeltsize
|
||||
INT TOKENS is_rom reg_loop ufit
|
||||
MOVES call kills reg_pointer uses
|
||||
PATTERNS cost lab regvar with
|
||||
PROPERTIES defined labeldef return yields
|
||||
REGISTERS exact leaving reusing
|
||||
SETS example loww rom
|
||||
SIZEFACTOR fallthrough move samesign
|
||||
STACK from pat sfit
|
||||
.TE
|
||||
C style comments are accepted.
|
||||
.DS
|
||||
|
@ -928,6 +929,17 @@ If
|
|||
.I t
|
||||
is omitted reg_any is assumed.
|
||||
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
|
||||
Token descriptions
|
||||
.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
|
||||
too often.
|
||||
.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
|
||||
rule,
|
||||
.I cg
|
||||
|
@ -1308,6 +1327,16 @@ C-routine
|
|||
Explanation of this must wait for the description of the
|
||||
file mach.c below.
|
||||
.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.
|
||||
Expressions of the form [0-9][bf] in this code rule
|
||||
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
|
||||
before the jump is taken.
|
||||
.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
|
||||
pat cal
|
||||
with STACK
|
||||
|
@ -2738,6 +2796,11 @@ DO_RETURN
|
|||
Returns from this level of codegen().
|
||||
Is used at the end of coercions,
|
||||
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
|
||||
compute.c
|
||||
.PP
|
||||
|
@ -2803,6 +2866,10 @@ This module maintains a list of global symbols that have a
|
|||
pseudo associated.
|
||||
There are functions to enter a symbol and to find a symbol.
|
||||
.NH 3
|
||||
label.c
|
||||
.PP
|
||||
This module contains routines to handle the top element size messages.
|
||||
.NH 3
|
||||
main.c
|
||||
.PP
|
||||
Main routine of the code generator.
|
||||
|
|
Loading…
Reference in a new issue