ANSI C -- static forward references

Gregory Smith greg at utcsri.UUCP
Sat Dec 20 06:08:37 AEST 1986


In article <114 at decvax.UUCP> minow at decvax.UUCP (Martin Minow) writes:
>Discussing my suggestion to change the interaction between "static"
>and "extern", Doug Gwyn (@ brl-smoke) notes that the Draft Standard's
>semantics were designed to permit one-pass compilation.
>
>Are there still true one-pass compilers being written today?  My impression
>is that the minimum hardware being sold today is something on the order
>of a Macintosh or Atari ST, both of which support full-featured, multi-pass
>compilers.  I would much prefer the Standard be written for the current
>(and future) "minimum" computer, rather than for some very limited
>10-year old microcomputer.

In article <264 at mordor.s1.gov> jdb at mordor.UUCP (John Bruner) writes:
>The last time I looked, PCC2 was a one-pass compiler.

I think there is some confusion here. C compilers are normally 'One-pass'
in the sense that they can generate code for X without requiring any
information about the source which appears after X. Assemblers (normal
assemblers anyway) cannot be one-pass in this sense, since they
need to resolve forward references.

A 'multi-pass' compiler is usually a bunch of programs which pipe
their data from one to the other (The PCC2 can be considered 2-pass in this
sense since it reads the output of the preprocessor). However, the
entire system acts as a one-pass compiler, again, since code (assembler)
is generated for X without knowing what comes after X.
To compile stuff on this machine, e.g. 'cc -o foo foo.c', foo.c
is run thru /bin/cpp, /bin/ccom, [ and /bin/c2 if you say -O ]. Then
the assembler makes two passes on the output, and the linker probably
makes two passes on the object module. Now do cpp and ccom count
as two passes? Some pcc implementations split ccom into two stages,
each of which is essentially a filter. Am I the only one who thinks
there is a terminology problem here? I would like to see the word 'stage'
used for a section of a pipe, while 'pass' refers to the number of
times a module must read its input stream. So a compiler could
be referred to as a '3-stage, 1-pass' compiler.

Of course, the distinction applies whether pipes or intermediate files
are used between stages. The use of temp files to delay such things as
string constants is not really an issue here, since it has such a minor
impact on the compiler design (Strictly speaking, when a pcc reopens
this temp file in order to spool its contents onto the end of the .s
file, it is making a second pass, since it is 'backing up' and
re-examining information gleaned from the first 'pass').


-- 
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg
Have vAX, will hack...



More information about the Comp.lang.c mailing list