home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / compiler / 1416 < prev    next >
Encoding:
Internet Message Format  |  1992-08-20  |  2.1 KB

  1. Xref: sparky comp.compilers:1416 comp.lang.c:12583
  2. Path: sparky!uunet!stanford.edu!rutgers!faatcrl!iecc!compilers-sender
  3. From: mcrware!adam@uunet.UU.NET (Adam Goldberg)
  4. Newsgroups: comp.compilers,comp.lang.c
  5. Subject: Re: Two-pass C compilers
  6. Keywords: C
  7. Message-ID: <92-08-115@comp.compilers>
  8. Date: 19 Aug 92 14:31:04 GMT
  9. References: <92-08-081@comp.compilers> <92-08-086@comp.compilers>
  10. Sender: compilers-sender@iecc.cambridge.ma.us
  11. Reply-To: mcrware!adam@uunet.UU.NET (Adam Goldberg)
  12. Organization: Microware Systems Corp., Des Moines, Iowa
  13. Lines: 37
  14. Approved: compilers@iecc.cambridge.ma.us
  15.  
  16. behrenss@Informatik.TU-Muenchen.DE (Soenke Behrens) writes:
  17. >Hmmm ... beat me if I something silly, but: Is there any way around
  18. >a two-pass compiler? (Or even more passes)
  19.  
  20. >First pass: Reading in the source, preprocessing it, building a symbol table.
  21. >Second pass: Generate p-Code
  22. >Third pass: Optimize p-Code (Note: Do not mix with 2nd pass or you are
  23. >in deep trouble)
  24. >Fourth pass: Generate native code in linkable object file
  25.  
  26. Perhaps I'm dense, but...
  27.  
  28. Is the 'First Pass' (as defined by Soenke) the preprocessor?  Even if it
  29. is, there's no great trick (seems to me) to preprocess, build a symbol
  30. table and output unoptimized p-Code all in the first pass through the
  31. source.  At that point, you've got p-Code (which is essentially an
  32. internal data representation of the source) to optimize, translate into
  33. assembler and assemble.  I would call this 1 pass for the following
  34. reasons:
  35.  
  36.  o The source code is read ONCE only.
  37.  o Take as many passes though the p-Code as you want; the p-Code is 
  38.    (essentially) an internal representation of the partially compiled
  39.    source.  Chomp on that N times, and you're still only playing with
  40.    internal data--hence, you have a 1 pass compiler, not a N+1 pass
  41.    compiler.
  42.  o The assembly output is again only an internal representation.
  43.    Assembling it is translating internal representation(s) into output.
  44.    Not a separate pass.
  45.  
  46.  
  47. -- 
  48. Adam G.
  49. adamg@microware.com, or ...!uunet!mcrware!adamg
  50. -- 
  51. Send compilers articles to compilers@iecc.cambridge.ma.us or
  52. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  53.