home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / i / icon / DOCS / IPD237_DOC next >
Text File  |  1995-12-01  |  17KB  |  529 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                  Version 9 of the Icon Compiler
  8.  
  9.                         Ralph E. Griswold
  10.     Department of Computer Science, The University of Arizona
  11.  
  12.  
  13. 1.__Introduction
  14.  
  15.    There are two forms of the implementation of Icon, an inter-
  16. preter and a compiler. The interpreter gets a program into execu-
  17. tion quickly and is recommended for program development, debug-
  18. ging, and most production situations. The compiler produces code
  19. that executes somewhat faster than interpreted code (a factor of
  20. 2 or 3 is typical), but the compiler requires a large amount of
  21. resources and is very slow in producing executable code. The com-
  22. piler is recommended only for small programs where execution
  23. speed is the paramount concern.
  24.  
  25.    In most respects, the Icon compiler is compatible with the
  26. Icon interpreter [1]. Most programs developed under the inter-
  27. preter run under the compiler with no changes.
  28.  
  29.    It takes considerably longer to compile an Icon program than
  30. it does to translate it for interpretation. In most cases, it is
  31. advisable to do program development using the interpreter and
  32. then produce a production version of the program with the com-
  33. piler.
  34.  
  35.    Since compiler support for some features of Icon makes it dif-
  36. ficult to produce fast executable code, these features are not
  37. available unless the compiler is told they are needed. This
  38. information is imparted by options to the compiler.
  39.  
  40.    The compiler performs a number of optimizations to improve
  41. run-time performance. These optimizations can be disabled.
  42.  
  43.    The Icon compiler produces C code, which is then compiled and
  44. linked to produce an executable program.  Programs produced by
  45. the compiler stand alone and do not require a separate run-time
  46. system like the interpreter.
  47.  
  48.    Only the routines needed by a compiled program are included in
  49. its executable file. Consequently, the size of a compiled program
  50. depends to a considerable extent on the range of features it
  51. uses.
  52.  
  53.    The compiler itself requires a significant amount of memory.
  54. It must read a data base into memory, maintain a representation
  55. of the entire program, and perform analyses.  Type inference in
  56. particular may require a large amount of memory, depending on the
  57. nature of the program.  Icon programs on the order of several
  58. thousand lines may require several megabytes of memory to com-
  59. pile. In case a program does not compile with type inference
  60. enabled due to memory limitations or compiles slowly due to
  61.  
  62.  
  63.  
  64. IPD237a                       - 1 -              October 31, 1995
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. excessive paging, it may compile satisfactorily with type
  74. inferencing disabled.
  75.  
  76.    The C code produced by the compiler is relatively voluminous
  77. and may require a large amount of disk space.  Disabling all
  78. optimizations typically doubles the size of the generated C code.
  79.  
  80.    Although the Icon compiler has been tested extensively at the
  81. Icon Project, it has not yet been used by a large and diverse
  82. programming community.  Further use will certainly uncover bugs.
  83. If a compiled program appears to malfunction, first be sure it
  84. works properly with the Icon interpreter.  Then try enabling
  85. optional features. Finally, try disabling all optimizations.
  86. Report bugs to the Icon Project.  Include enough information,
  87. including the program and data, so that the problem can be repli-
  88. cated.
  89.  
  90.    The next section describes how to run programs with the Icon
  91. compiler.  The last section describes differences in language
  92. features between the compiler and interpreter.
  93.  
  94.  
  95. 2.__Running_the_Compiler
  96.  
  97.    The Icon compiler is invoked with the command
  98.  
  99.         iconc [ options ] files [ -x [ args ] ]
  100.  
  101. where options can be any of the following:
  102.  
  103.   -c      stop compilation after producing C code
  104.   -e file redirect standard error output to file
  105.   -f s    enable features as indicated by the letters in s
  106.             a  - all, equivalent to delns
  107.             d  - enable debugging features, including the effect
  108.                of -f n (see below)
  109.             e  - enable error conversion
  110.             l  - enable large-integer arithmetic
  111.             n  - produce code that keeps track of line numbers
  112.                and file names in the source code
  113.             s  - enable full string invocation
  114.   -m      preprocess each source file with the m4 preprocessor
  115.                (UNIX only)
  116.   -n s    disable specific optimizations. These are indicated by the
  117.                letters in s:
  118.             a  - all, equivalent to cest
  119.             c  - control flow optimizations other than switch
  120.                statement optimizations
  121.             e  - expand operations in-line when reasonable
  122.                (keywords are always put in-line)
  123.             s  - optimize switch statements associated with
  124.             t  - type inference
  125.   -o file use file as the name of the executable file
  126.   -p arg  pass arg on to the C compiler used by iconc
  127.  
  128.  
  129.  
  130. IPD237a                       - 2 -              October 31, 1995
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.   -r path use the run-time system at path.
  140.   -s      suppress informative messages from the compiler
  141.   -t      enable debugging features as for -f d and initialize &trace to -1
  142.   -u      issue warning messages for undeclared identifiers in the program
  143.   -v i    set verbosity level of informative messages to i
  144.   -C prg  have iconc use the C compiler given by prg
  145.  
  146. File_Names
  147.  
  148.    One or more source file names must be specified. If a name has
  149. no suffix, .icn is appended. Otherwise, the name must already
  150. have a suffix of .icn. The argument ``-'' indicates that the
  151. source should be read from standard input. If the -o option is
  152. not used, the name of the executable file is constructed from the
  153. name of the first source file; stdin is used for ``-''. The com-
  154. piler produces a C program source file and a C include file as
  155. intermediate files. The names of these files are constructed from
  156. the name of the executable file.  For example,
  157.  
  158.         iconc prog.icn
  159.  
  160. creates prog.c and prog.h. These files subsequently are deleted
  161. unless the -c option is specified. In any event, any previous
  162. versions of prog.c and prog.h are overwritten.
  163.  
  164. Options
  165.  
  166.    See Section 3 for a description of features enabled by the -f
  167. options.  Use of these features may reduce the optimizations per-
  168. formed by the compiler.
  169.  
  170.    The -p option passes its argument to the C compiler. For exam-
  171. ple,
  172.  
  173.         iconc -p "-w"
  174.  
  175. might be used to suppress warning messages.  -p options accumu-
  176. late; -p "" clears the list of options, including the initial set
  177. of standard options.
  178.  
  179.    The -r option allows specification of the location of the
  180. directory that contains files needed by iconc. This overrides the
  181. default location.  The path argument must be terminated by a
  182. slash, as in
  183.  
  184.         iconc -r /usr/icon/lib/
  185.  
  186.  
  187.    The -v option controls the level of detail of iconc's informa-
  188. tive messages. -v 0 is the same as -s.  -v 1 is the default
  189. behavior.  Presently -v 2 and -v 3 only affect messages during
  190. type inferencing and are useful for monitoring its progress on
  191. large programs.  -v 2 causes a dot to be written for each itera-
  192. tion of type inferencing. -v 3 writes an indication of the amount
  193.  
  194.  
  195.  
  196. IPD237a                       - 3 -              October 31, 1995
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205. of information found in each iteration of type inferencing.
  206.  
  207.    The -C option can be used to override the default C compiler
  208. used by iconc. It is possible, although unlikely, that using a
  209. different C compiler than the one expected when iconc is built
  210. may produce code incompatibilities.
  211.  
  212.    As noted earlier, the -n t option sometimes is needed when
  213. compiling very large programs. The other -n options are used
  214. mostly for debugging the compiler.
  215.  
  216.    Disabling control-flow optimizations by -n c may result in
  217. unreachable C code and corresponding warning messages when it is
  218. compiled. Such messages may be annoying, but they can safely be
  219. ignored.  Occasionally unreachable C code may occur even with
  220. control-flow optimizations. This may indicate unreachable Icon
  221. code.
  222.  
  223. Environment_Variables
  224.  
  225.    The co