home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / ada / 3792 < prev    next >
Encoding:
Text File  |  1992-12-22  |  14.0 KB  |  299 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!seas.gwu.edu!mfeldman
  3. From: mfeldman@seas.gwu.edu (Michael Feldman)
  4. Subject: Re: GNU Ada9X progress?
  5. Message-ID: <1992Dec21.235156.15545@seas.gwu.edu>
  6. Sender: news@seas.gwu.edu
  7. Organization: George Washington University
  8. References: <del.724923147@hawk>
  9. Date: Mon, 21 Dec 1992 23:51:56 GMT
  10. Lines: 287
  11.  
  12. In article <del.724923147@hawk> del@hawk.adied.oz.au (D Elson) writes:
  13. >
  14. >Can someone from the group (or anyone else at NYU [?] who knows the group)
  15. >that is working on the GNU Ada 9x project please give me some information
  16. >on it?  I would like to know the target platform[s], and the expected
  17. >completion/release dates.
  18. The Nov. 1992 GNAT report is attached below.
  19. >
  20. >Also -- will there be a mechanism so that software developers can create
  21. >bindings to non-Ada language products using GNU Ada9X?
  22. I can't say for sure that they will implement PRAGMA Interface, because
  23. I've never asked. But they did so in Ada/Ed-C, and I've used it with
  24. some success. I cannot imagine why they wouldn't do it, as it's one
  25. of the standard Ada pragmas.
  26. >
  27. Mike Feldman
  28. ------------------------------------------------------------------------
  29. Michael B. Feldman
  30. co-chair, SIGAda Education Committee
  31.  
  32. Professor, Dept. of Electrical Engineering and Computer Science
  33. School of Engineering and Applied Science
  34. The George Washington University
  35. Washington, DC 20052 USA
  36. (202) 994-5253 (voice)
  37. (202) 994-5296 (fax)
  38. mfeldman@seas.gwu.edu (Internet)
  39.  
  40. "Americans want the fruits of patience -- and they want them now."
  41. ------------------------------------------------------------------------
  42. From schonber@SCHONBERG.CS.NYU.EDU Wed Nov 11 02:48:06 1992
  43. Received: from CS.NYU.EDU by gwusun.seas.gwu.edu with SMTP id AA28867
  44.   (5.65c/IDA-1.4.4 for <mfeldman@seas.gwu.edu>); Wed, 11 Nov 1992 02:47:47 -0500
  45. Received: from SCHONBERG.CS.NYU.EDU by cs.NYU.EDU (5.61/1.34)
  46.     id AA18261; Mon, 2 Nov 92 15:42:39 -0500
  47. Received: by SCHONBERG.CS.NYU.EDU (5.61/1.34)
  48.     id AA05318; Mon, 2 Nov 92 15:42:37 -0500
  49. Date: Mon, 2 Nov 92 15:42:37 -0500
  50. From: schonber@SCHONBERG.CS.NYU.EDU (Ed Schonberg)
  51. Message-Id: <9211022042.AA05318@SCHONBERG.CS.NYU.EDU>
  52. To: gnat-world@cs.NYU.EDU
  53. Subject: GNAT progress report
  54. Status: OR
  55.  
  56.  
  57.  
  58.              GNAT Project
  59.             GNU-NYU Ada Translator.
  60.  
  61.            GNAT Report 0001-921101
  62.  
  63.               November 1, 1992
  64.  
  65. 1. Introduction.
  66. ----------------
  67.  
  68. This is the first summary of activities of the project since its official
  69. start in July 1992. The goal of the project is the construction of a portable
  70. Ada9X compiler, based on the following three components: 
  71.  
  72. a) The very successful GCC back-end. 
  73.  
  74. b) The Ada/Ed front-end and tasking library.
  75.  
  76. c) The Ada9X extensions developed by the Implementation Analysis Team
  77. (i.e. the NYUADA project) itself) as part of the Ada9X project.  
  78.  
  79. We will demonstrate some of the running portions of the system at the 
  80. Triada92 conference this month in Orlando. To sum up: the parser is complete,
  81. the semantic analyzer handles basic declarations, subprograms and packages,
  82. the tree transformer can process basic declarations and statement forms, all
  83. of which makes it possible to execute very simple programs. We are on
  84. schedule to demonstrate most of the Ada9X functionality at the Ada/Europe
  85. conference in June 1993, and to demonstrate a fully bootstrapped system in
  86. December 1993, which is the end date of the project. 
  87.  
  88. We have focused much of our work on the design and implementation of 
  89. convenient abstract interfaces between phases of the compiler. This is
  90. one of the obvious benefits of the use of Ada, but we were struck by the way
  91. in which the language forced us in this direction, and led us to complete
  92. and polished interfaces first. A small testimonial to the extent to which
  93. the language can influence good design.
  94.  
  95. II. System overview.
  96. --------------------
  97.  
  98. The GNAT system includes the following modules:
  99.  
  100. a) A scanner and parser, written in Ada 83. The parser produces an abstract
  101. syntax tree with sufficient information to reproduce exactly the source
  102. program (including token placement).
  103.  
  104. b) A semantic analyzer, which annotates the AST with type information,
  105. performs name and overload resolution, and a large number of legality
  106. checks. The output of the semantic analyzer is the annotated AST. This
  107. phase is written in Ada 83 as well.
  108.  
  109. c) A tree transformer that traverses the AST and constructs a semantically
  110. equivalent tree, which is input to the GCC back end. This phase is written
  111. in C. Communication between semantics and transformation is by means of a
  112. file (at least conceptually).
  113.  
  114. d) An enhanced GCC back end, which emits all required constraint checks
  115. and recognizes all instructions that may raise hardware exceptions. 
  116.  
  117. e) A library manager. To maximize compatibility with the current library
  118. model of GCC, no separate library file is created, but all necessary library
  119. information is stored directly in .o files, and recreated when needed by
  120. the library manager. We retain the basic principle that the compilation of
  121. one source file produces one object file. This is not a conventional model
  122. for Ada systems, but it will simplify the construction of mixed-language
  123. systems, and will look very familiar to the Unix community.  The library
  124. manager is written in Ada.
  125.  
  126. f) An Ada-specific binder that assembles subunits, performs late inlining
  127. and generic instantiations, and removes unnecessary access-before-elaboration
  128. checks. This is written in Ada.
  129.  
  130. g) A run-time system, whose main components are: tasking, I/O, and exception
  131. handling. Most of this is written in Ada.
  132.  
  133. The following sections detail the design and current status of each of these.
  134.  
  135. III. The Scanner/Parser.
  136. ------------------------
  137.  
  138. The scanner/parser is complete. We have no performance figures yet, but
  139. it appears to be (when compiling itself) more than an order of magnitude
  140. faster than the previous Ada/Ed parser. The current parser derives from 
  141. an Ada 83 syntax checker written by R.B.K.D in assembly language, whose
  142. awesome performance was of the order of 1,000,000 lines/min on a 16 Mz 386.
  143. Even without any more precise figures, we are confident that this will not 
  144. be the bottleneck of the system!
  145.  
  146. The parser uses recursive descent and has an elaborate error recovery
  147. mechanism, which includes heuristics to make use of program indentation
  148. (on the reasonable assumption that most programmers use indentation to
  149. reflect significant aspects of the nesting structure of their program). 
  150. The parser produces almost no cascaded errors on all the ACVC B-tests,
  151. and seems to recover as well as the previous LALR parser of Ada/Ed.
  152. The parser includes an Ada83 switch. Note however that we have no plans
  153. of producing a complete Ada 83 system: our goal is Ada 9X, and we are
  154. NOT starting with an Ada 83 subset.  
  155.  
  156. IV. The Abstract Syntax Tree.
  157. -----------------------------
  158.  
  159. The Scanner/Parser produces an AST and a names table. The low-level details
  160. of the data-structure are hidden by means of a procedural interface, which
  161. includes a retrieval procedure for each non-terminal in the language. All
  162. these retrieval procedures are intended to be inlined, but currently they
  163. include copious tracing and debugging information. In the interest of
  164. efficiency, we have chosen to use very simple data structures to describe the
  165. AST (for example, we make no use of discriminated records) and the code
  166. includes a significant amount of internal consistency checks (essentially,
  167. a small but strategically placed collection of discriminant checks). Some
  168. future version of GNAT, written in Ada 9X, might display an agressive
  169. use of tagged types and type extensions.
  170.  
  171. There is no separate symbol table. Each defining identifier (i.e. the
  172. defining occurrence of a program entity) is annotated with semantic
  173. information, such as its type. Each use occurrence is made to point to the
  174. corresponding defining occurrence, after name resolution. The AST thus
  175. resembles a DIANA representation. Although we have not examined the question
  176. in full detail, it seems that our AST structure will support an ASIS package
  177. with very little effort.
  178.  
  179. Two packages provide interfaces to the AST: Syntax_Info describes the
  180. tree as it is produced by the parser, and Entity_Info describes the
  181. semantic annotations. Both of these interfaces are completely procedural:
  182. no indication of the actual layout of AST nodes is visible to any client of 
  183. front-end. To support the code of the tree transformer, which is written in
  184. C, there are C translations of these packages. The header files for these
  185. are produced automatically (by means of a SPITBOL program) to insure that
  186. they remain consistent with the Ada versions.
  187.  
  188. V. The Semantic Analyzer.
  189. -------------------------
  190.  
  191. The semantic analyzer performs several traversals of the AST, to produce
  192. semantic annotations, apply legality checks, and expand constructs whose
  193. direct translation into the GCC tree form would be awkward (e.g. aggregates). 
  194. The first (and largest) pass of the analyzer performs name, type and
  195. overload resolution, and collects most semantic attributes. This phase is
  196. being written following the general organization of the Ada/Ed front-end
  197. (the SETL version, which includes already such Ada9X features as tagged
  198. types and extensions, and generic formal packages).  We have chosen the
  199. following package structure for this phase: there is one package for each
  200. chapter of the Ada Reference manual, and one driver package. All chapter
  201. packages are subunits of the driver. 
  202.  
  203. package Sem1 is                 -- Driver 
  204.     procedure Analyze (T: Node_ID);        -- top-level procedure.
  205.     package Sem2 is ...                -- pragma handling.
  206.     package Sem3 is ...                -- declarations and types.
  207.     ...
  208. end Sem1;
  209. package body Sem1 is
  210.     ...
  211.     package body Sem2 is separate.
  212.     package body Sem4 is separate.
  213.     ...
  214. end Sem1 ;
  215.     
  216. Use clauses in each proper body simplify the invocation of procedures
  217. that are used everywhere (for example, all packages use Sem4 and Sem8, but
  218. no one needs easy access to the contents of Sem11). 
  219.  
  220. As of 11/1, enough of Sem1, Sem3, Sem5, Sem6, Sem7, and Sem8 is written
  221. to handle scalar declarations and types, control structures, subprograms
  222. and calls, packages, and simple name resolution. The design of overload
  223. resolution data structures and algorithms is complete but not implemented
  224. yet. 
  225.  
  226. VI. The Tree transformer.
  227. -------------------------
  228.  
  229. The tree transformer performs the critical task of mapping the semantics
  230. the AST into the corresponding GCC tree, mimicking the actions of other
  231. GCC front-ends. This is done by traversing the AST and invoking tree
  232. constructors provided in GCC to  build tree fragments that are eventually
  233. assembled into the tree of one complete compilation unit. The traversal of
  234. the AST uses the procedural interfaces described above. The description of
  235. the GCC tree constructors can be found in the GCC documentation, and we will
  236. not say anything about it here, except to indicate that Ada-specific nodes
  237. have been added, to describe constraint checks on expressions and values.
  238. We expect to make a few additional extensions to the GCC tree, but we intend
  239. to keep them to a minimum. For example, the handling of in-out parameters
  240. is done currently by special casing single parameters and by constructing
  241. a record that is passed by reference in the case of multiple in-out parameters.
  242. This can be done without any modifications to the GCC tree structure.
  243.  
  244. On the other hand, semantic details that may be of use to other GCC
  245. languages will be implemented directly in the code generator. This is the
  246. case of exceptions for example, given that they will be used by C++ as well
  247. as Ada.
  248.  
  249. We explored (for the space of a week) the option of writing the transformer
  250. in Ada, with extensive use of the pragma INTERFACE to invoke the GCC
  251. tree constructors. In spite of the appeal of writing more of the system in
  252. Ada, we decided that this would lead to a system that would be exceedingly
  253. difficult to design cleanly, that would be hard to debug, and that would
  254. lead to messy heterogeneous structures.
  255. As of 11/1, the tree transformer can generate the GCC trees corresponding 
  256. to subprograms, simple control structures, and arithmetic expressions. 
  257.  
  258. VIII. The code generator.
  259. -------------------------
  260.  
  261. The GCC back end is of course the largest portion of the system. It includes
  262. a multi-pass retargetable code generator, and has been ported to more than
  263. 25 machines so far. It generates excellent code, comparable (and at times
  264. superior) to that of the best commercial compilers. The architectural
  265. details of each target are encapsulated in a machine description file that
  266. specifies precisely the semantics of all machine operations, in terms of a
  267. common register transfer language. In order to support Ada, the machine
  268. description formalism must be extended to specify more precisely the 
  269. relationship between instructions and exceptions. The code generator must
  270. respect Ada semantics and inhibit code motion where prohibited. Richard Kenner,
  271. the author of several GCC ports, and Richard Stallman, the creator of GCC,
  272. are designing these extensions. 
  273.  
  274. IX. The library manager.
  275. ------------------------
  276.  
  277. Design of the library manager is in its very early stages. We have decided
  278. that the information to be stored in object files is only that found in the
  279. AST, i.e. no GCC-generated information is ever preserved. This means that
  280. the GCC trees that correspond to package specifications appearing in a context
  281. clause are reconstructed rather than just retrieved. This corresponds to
  282. the standard handling of header files in C, and does not seem to be onerous
  283. (but once we have measurements we may change our minds!). Similarly, stack
  284. layout is recomputed as needed. This adds to the cost of compiling proper
  285. bodies of subunits, but given that the compilation of proper bodies requires
  286. reconstructing the visibility environment of the stub, all the declarations
  287. that are visible at the location of the stub must be reprocessed anyway. The
  288. advantage is that the library manager has deal only with one data structure,
  289. namely the AST.
  290.  
  291. VII.  The rest.
  292. ---------------
  293.  
  294. The design of the  binder and run-time system will be described in future
  295. reports. As portions of the system become more stable we will make public
  296. those interfaces that seem mature enough for external consumption.
  297.  
  298.  
  299.