3. How to use C Compiler
Contents
3.1. How to Compile this Compiler
The COINS infrastructure includes the
class coins.driver.Driver that serves as the driver of a
C compiler. The target machine architecture can be selected from the
following list:
- sparc ...... SUN SPARC (mult/div is a subroutine)
- sparc-v8 ... SUN SPARC (mult/div is a machine instruction)
- x86 ........ Intel i386
- arm ........ ARM
- mips ....... MIPS
- sh4 ........ Hitachi SH-4
- ppc ........ IBM PowerPC
All the classes of COINS are precompiled into the directory 'classes', so you can
try to compile your C programs immediately.
If you wish to compile the compiler yourself, do the following:
3.2. How to Execute the Compiler
3.2.1. Short Descriptions
Follow the following procedures:
On UNIX running a sh-compatible shell, type
export CLASSPATH=$HOME/Java/coins-1.x.y/classes
## Change according to your environment.
or for Windows
SET CLASSPATH=c:\home\Java\coins-1.x.y\classes
## Change according to your environment.
Then on either platform type
java coins.driver.Driver -S xxx.c
or
java -classpath ./classes coins.driver.Driver -S xxx.c
To specify the target machine add the option "-b arch"
to the above command, where arch is sparc, sparc-v8, x86,
arm, mips, sh4, or ppc. The default is "sparc".
Debug information will be printed if the following command is used.
java coins.driver.Driver -S -coins:trace=Sym.1/HIR.1/back xxx.c
or
java -classpath ./classes coins.driver.Driver -S -coins:trace=Sym.1/HIR.1/back xxx.c
(if class files are under 'classes')
where, "trace= ..." specifies debug control and the number "1" in "Sym.1",
etc. is a trace level. "Sym" in "Sym.1" is a trace category. Large
trace categories number (e.g. 500, 10000) may produce a huge amount
of debug print.
Available trace categories are described in
2.3.4. -coins Options.
Object code (xxx.s) will be generated on the same directory
as that of source program xxx.c. It can be executed by
cc xxx.s; ./a.out or ./a.exe
For more information on C compiler driver coins.driver.Driver, see
2. How to use the Compiler Driver.
3.2.2. Required Software
COINS C compiler driver requires following commands to execute compilation:
- cpp
- gas
- gcc (as a linker)
Prior to compilation, make sure that you can invoke these commands
(i.e., include them in your execution path). If you don't have
these commands but have alternatives (e.g., 'as' for 'gas'),
the driver provides a way to specify alternative commands.
For more detail, see
- -coins:preprocessor/assembler/linker
options described in 2.3.4. -coins Options.
3.3. Automatic Test of the Compiler
Many test programs are prepared under Test/C directory.
They are arranged for automatic test by the shell script
"testcoins.sh" that is placed under the Test directory.
Preparation procedure for the automatic test is explained
in test/c/testprepare.txt (in Japanese).
3.4. Unsupported Features
This compiler supports language facilities specified in
- ISO/IEC 9899:1990 Programming Language C
except for following features:
- preprocessing
- library
- long double (the size is same as double)
- wchar_t and L"xx" string
As for preprocessor and library, it is recommended to use
those of gcc.