home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
i
/
icon
/
DOCS
/
IPD237_DOC
next >
Wrap
Text File
|
1995-12-01
|
17KB
|
529 lines
Version 9 of the Icon Compiler
Ralph E. Griswold
Department of Computer Science, The University of Arizona
1.__Introduction
There are two forms of the implementation of Icon, an inter-
preter and a compiler. The interpreter gets a program into execu-
tion quickly and is recommended for program development, debug-
ging, and most production situations. The compiler produces code
that executes somewhat faster than interpreted code (a factor of
2 or 3 is typical), but the compiler requires a large amount of
resources and is very slow in producing executable code. The com-
piler is recommended only for small programs where execution
speed is the paramount concern.
In most respects, the Icon compiler is compatible with the
Icon interpreter [1]. Most programs developed under the inter-
preter run under the compiler with no changes.
It takes considerably longer to compile an Icon program than
it does to translate it for interpretation. In most cases, it is
advisable to do program development using the interpreter and
then produce a production version of the program with the com-
piler.
Since compiler support for some features of Icon makes it dif-
ficult to produce fast executable code, these features are not
available unless the compiler is told they are needed. This
information is imparted by options to the compiler.
The compiler performs a number of optimizations to improve
run-time performance. These optimizations can be disabled.
The Icon compiler produces C code, which is then compiled and
linked to produce an executable program. Programs produced by
the compiler stand alone and do not require a separate run-time
system like the interpreter.
Only the routines needed by a compiled program are included in
its executable file. Consequently, the size of a compiled program
depends to a considerable extent on the range of features it
uses.
The compiler itself requires a significant amount of memory.
It must read a data base into memory, maintain a representation
of the entire program, and perform analyses. Type inference in
particular may require a large amount of memory, depending on the
nature of the program. Icon programs on the order of several
thousand lines may require several megabytes of memory to com-
pile. In case a program does not compile with type inference
enabled due to memory limitations or compiles slowly due to
IPD237a - 1 - October 31, 1995
excessive paging, it may compile satisfactorily with type
inferencing disabled.
The C code produced by the compiler is relatively voluminous
and may require a large amount of disk space. Disabling all
optimizations typically doubles the size of the generated C code.
Although the Icon compiler has been tested extensively at the
Icon Project, it has not yet been used by a large and diverse
programming community. Further use will certainly uncover bugs.
If a compiled program appears to malfunction, first be sure it
works properly with the Icon interpreter. Then try enabling
optional features. Finally, try disabling all optimizations.
Report bugs to the Icon Project. Include enough information,
including the program and data, so that the problem can be repli-
cated.
The next section describes how to run programs with the Icon
compiler. The last section describes differences in language
features between the compiler and interpreter.
2.__Running_the_Compiler
The Icon compiler is invoked with the command
iconc [ options ] files [ -x [ args ] ]
where options can be any of the following:
-c stop compilation after producing C code
-e file redirect standard error output to file
-f s enable features as indicated by the letters in s
a - all, equivalent to delns
d - enable debugging features, including the effect
of -f n (see below)
e - enable error conversion
l - enable large-integer arithmetic
n - produce code that keeps track of line numbers
and file names in the source code
s - enable full string invocation
-m preprocess each source file with the m4 preprocessor
(UNIX only)
-n s disable specific optimizations. These are indicated by the
letters in s:
a - all, equivalent to cest
c - control flow optimizations other than switch
statement optimizations
e - expand operations in-line when reasonable
(keywords are always put in-line)
s - optimize switch statements associated with
t - type inference
-o file use file as the name of the executable file
-p arg pass arg on to the C compiler used by iconc
IPD237a - 2 - October 31, 1995
-r path use the run-time system at path.
-s suppress informative messages from the compiler
-t enable debugging features as for -f d and initialize &trace to -1
-u issue warning messages for undeclared identifiers in the program
-v i set verbosity level of informative messages to i
-C prg have iconc use the C compiler given by prg
File_Names
One or more source file names must be specified. If a name has
no suffix, .icn is appended. Otherwise, the name must already
have a suffix of .icn. The argument ``-'' indicates that the
source should be read from standard input. If the -o option is
not used, the name of the executable file is constructed from the
name of the first source file; stdin is used for ``-''. The com-
piler produces a C program source file and a C include file as
intermediate files. The names of these files are constructed from
the name of the executable file. For example,
iconc prog.icn
creates prog.c and prog.h. These files subsequently are deleted
unless the -c option is specified. In any event, any previous
versions of prog.c and prog.h are overwritten.
Options
See Section 3 for a description of features enabled by the -f
options. Use of these features may reduce the optimizations per-
formed by the compiler.
The -p option passes its argument to the C compiler. For exam-
ple,
iconc -p "-w"
might be used to suppress warning messages. -p options accumu-
late; -p "" clears the list of options, including the initial set
of standard options.
The -r option allows specification of the location of the
directory that contains files needed by iconc. This overrides the
default location. The path argument must be terminated by a
slash, as in
iconc -r /usr/icon/lib/
The -v option controls the level of detail of iconc's informa-
tive messages. -v 0 is the same as -s. -v 1 is the default
behavior. Presently -v 2 and -v 3 only affect messages during
type inferencing and are useful for monitoring its progress on
large programs. -v 2 causes a dot to be written for each itera-
tion of type inferencing. -v 3 writes an indication of the amount
IPD237a - 3 - October 31, 1995
of information found in each iteration of type inferencing.
The -C option can be used to override the default C compiler
used by iconc. It is possible, although unlikely, that using a
different C compiler than the one expected when iconc is built
may produce code incompatibilities.
As noted earlier, the -n t option sometimes is needed when
compiling very large programs. The other -n options are used
mostly for debugging the compiler.
Disabling control-flow optimizations by -n c may result in
unreachable C code and corresponding warning messages when it is
compiled. Such messages may be annoying, but they can safely be
ignored. Occasionally unreachable C code may occur even with
control-flow optimizations. This may indicate unreachable Icon
code.
Environment_Variables
The co