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

  1. Path: sparky!uunet!wupost!uwm.edu!rutgers!faatcrl!iecc!compilers-sender
  2. From: sasghm@unx.sas.com (Gary Merrill)
  3. Newsgroups: comp.compilers
  4. Subject: Re: Two-pass C compilers
  5. Keywords: C, design
  6. Message-ID: <92-08-096@comp.compilers>
  7. Date: 17 Aug 92 17:14:59 GMT
  8. References: <92-08-081@comp.compilers> <92-08-086@comp.compilers>
  9. Sender: compilers-sender@iecc.cambridge.ma.us
  10. Reply-To: Gary Merrill <sasghm@unx.sas.com>
  11. Organization: Compilers Central
  12. Lines: 46
  13. Approved: compilers@iecc.cambridge.ma.us
  14.  
  15. As posed, this question is a pseudo-question and is unanswerable.  The
  16. answer hinges on what we mean by "pass".  As John has pointed out, the
  17. "classical" meaning of pass (as applied to assemblers) pertains to the
  18. number of times the *source* is read.  With high- level languages, the
  19. concept of pass becomes a bit more murky, and even in the best texts there
  20. is confusion.
  21.  
  22. For example, in _The_Theory_and_Practice_of_Compiler_Writing_, Tremblay
  23. and Sorenson first define "separate pass" as meaning "examine the entire
  24. source program".  Yet two paragraphs later they conflate "phase" and
  25. "pass" (using both terms) in such assertions as
  26.  
  27.     [T]he optimization phase may require that several
  28.         passes of the source program (or its intermediate
  29.         form) be made.
  30.  
  31. and then
  32.  
  33.     [T]he optimization phase is often spread throughout
  34.     the other pases of the compilation process ...
  35.  
  36. I find this second statement especially puzzling, but it is clear that
  37. they intend to extend the idea of "pass" to include the processing of an
  38. intermediate representation.
  39.  
  40. If we employ this broader notion of "pass", then every C compiler known to
  41. me is multi-pass.  Whether the intermediate representation is in a file on
  42. the disk, in memory, or on my notepad is irrelevant.  (Note that
  43. frequently the intermediate representation is not textual in nature, but
  44. is a binary representation of a tree or a set of quadruples.  In fact,
  45. there may be *several* intermediate representations, depending upon how
  46. much and what kind of optimization is desired.)  But if we employ the
  47. narrower (classical) notion of "pass", then every C compiler known to me
  48. is single pass since I know of none (there *may* be some, but I can't
  49. imagine why) that read the original source more than once.  Even those
  50. compilers that first generate a file of tokenized input (at least the old
  51. Whitesmith's compiler used to do this) are single pass since they read the
  52. original source only once.
  53.  
  54. ---
  55. Gary H. Merrill  [Principal Systems Developer, C Compiler Development]
  56. SAS Institute Inc. / SAS Campus Dr. / Cary, NC  27513 / (919) 677-8000
  57. sasghm@theseus.unx.sas.com ... !mcnc!sas!sasghm
  58. -- 
  59. Send compilers articles to compilers@iecc.cambridge.ma.us or
  60. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  61.