In the United States, Intel literature may be obtained by writing:
Literature Distribution Center
Intel Corporation
P.O. Box 7641
Mt. Prospect, IL 60056-7641
Or you can call the following toll-free number:
1-800-548-4725
In locations outside the United States, contact your local Intel sales office.
Intel Corporation makes no warranty of any kind with regard to this material, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose. Intel Corporation assumes no responsibility for any
errors that may appear in this document. Intel Corporation makes no commitment to update nor to keep current the
information contained in this document.
Intel Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in an Intel
product. No other circuit patent licenses are implied.
Intel software products are copyrighted by and shall remain the property of Intel Corporation. Use, duplication or
disclosure is subject to restrictions stated in Intel's Software License Agreement, or in the case of software delivered to
the government, in accordance with the software license agreement as defined in FAR 52.227-7013.
No part of this document may be copied or reproduced in any form or by any means without prior written consent of
Intel Corporation.
Intel Corporation retains the right to make changes to these specifications at any time, without notice.
Contact your local sales office or distributor to obtain the latest specifications before placing your order.
* Other brands and names are the property of their respective owners.
printed on
recycled paper
Copyright 1996, 1997. Intel Corporation. All rights reserved.
7-3Return Value Class Matching....................................7-75
7-4Argument Category to Parameter Class Matching
and Coercion.............................................................7-75
7-5C Data Types and asm Classes................................7-78
8-1Architecture Macros and Compatibility......................8-2
level
11-1 Optimizations and O
Settings ............................11-2
11-2 Examples of Constant Expression Evaluation...........11-4
11-3 Examples of Identity Collapsing................................11-6
xi
The CTOOLS Compilation System
This manual provides operating instructions and other information on the
CTOOLS compilation system. This system consists of a compiler and two
drivers that provide the user interface to the compiler, gcc960 and ic960.
These two interface drivers allow backward compatibility with software
developed using GNU/960 and CTOOLS960 respectively.
Features
The compiler lets you use the following features to develop applications:
• Use of either the gcc960 or ic960 compiler driver to invoke and
control translation and linking.
• Creation of a run-time performance profile of your application.
Optimizations based on this profile include inter-module optimizations
and preferential use of fast memory regions for variables that are
heavily used. For an overview of the program-wide optimization
process, including profile-driven optimization, see Chapter 4. For
descriptions of other optimizations, refer to Chapter 11.
• Calling
text, or including in-line assembly language in your C program.
• Stopping the compilation process to examine intermediate results after
syntax checking, preprocessing, compilation, assembly, or incremental
linking. (See Chapters 2 and 3.)
• Using a single command to translate and link modules into a complete
ROM-able or executable program. (See Chapters 2 and 3.)
functions written in i960 processor assembly language source
1
1-1
1
i960 Processor Compiler User's Guide
• Using the CAVE pragma to compress functions, thus reducing code
size. During program execution, these functions are decompressed
when called. For more information on the CAVE and other pragmas,
see Chapter 7.
• Creating blended code with the new
options. With these options, you can generate code that is compatible
with multiple i960 processor types. For more information, see
Chapters 2 and 3.
-mcore0-3 and -Gcore0-3
Compatibility and Conformance to Standards
The compiler runs on a UNIX* or a Windows* 95/NT* host system and
generates object code for any i960 commercial processor. The translation
and code generation phases use the instruction set for the i960 processor
that you specify.
The compiler's implementation of C conforms to the ANSI standard for
the C language (X3.159-1989). One exception is static pointer
initialization in applications using position-independent code or data
(described in Chapter 9). Additionally, the compiler allows use of in-line
assembly language in the C source text.
1-2
The ANSI standard specifies that a conforming implementation of a C
compiler must meet minimum requirements for certain translation limits.
In all cases, the compiler exceeds ANSI limits. Table 1-1 lists the tested
levels for each translation limit and compares them to ANSI minimum
requirements. Available memory determines actual limits in a host
system.
The CTOOLS Compilation System
Tested
Minimum
128
32
32
64
128
128
33
1024
4096
128
4096
4096
65535
32
1024
512
512
64
2048
128
Table 1-1Compiler Limits
Limit
Control structure nesting levels15
Conditional compilation nesting levels6
Declarator modifiers12
Declaration parenthesis nesting levels31
Parenthesis nesting levels32
Significant characters for internal identifier31
Name length for external identifier6
Identifiers in a single block127
Macros simultaneously defined1024
Parameters per function call31
Characters in a logical line509
Characters in a string509
Bytes in an object32767
Include file nesting levels8
Case labels in a switch257
Members in one structure or union127
Enumeration constants in one enumeration127
Structure nesting levels15
External identifiers per file511
Parameters per macro31
1
ANSI
Minimum
1-3
1
i960 Processor Compiler User's Guide
About this Manual
This manual contains the following chapters:
Table 1-2Chapter Descriptions
Chapter
NumberTitleDescription
1. The CTOOLS
Compilation
System
2. gcc960 Compiler
Driver
3. ic960 Compiler
Driver
4. Program-wide
Analysis and
Optimization
5. Profile Data
Merging and
Data Format
(gmpf960)
6. gcdm Decision
Maker Option
Introduces the compiler and provides
information on using this manual.
Teaches you how to use the gcc960
command-line interface and provides a
complete list of command line options.
Teaches you how to use the ic960 commandline interface and provides a complete list of
command line options.
Tells you how to use some of CTOOLS most
powerful optimization features:
• individual module optimizations
• program-wide optimizations
• run-time profiling
Explains how to use gmpf960 to merge the
execution profile data you collected in
Chapter 4. You also learn how to use
gmpf960 to create a report that shows how
many times each basic block was “hit” or run
during program execution.
Describes the gcdm option, which invokes the
gcdm960 global optimization decision maker
during the link process. The decision maker
then invokes the compiler and linker as
necessary to perform program-wide
optimizations.
1-4
continued
☛
The CTOOLS Compilation System
Table 1-2Chapter Descriptions (continued)
Chapter
NumberTitleDescription
7. Language
Implementation
Describes data representation, register use,
object file format use, and pragmas for
modifying code generation.
1
8. gcc960 / ic960
Compatibility
9. Position
Independence
and Reentrancy
10. Initializing the
Execution
Environment
11. OptimizationDescribes the different ways in which the
Describes the incompatibilities between ic960
and gcc960.
Provides information on writing i960
processor applications that require positionindependent or reentrant programs.
Describes the initialization process for the
i960 processor execution environment,
including the startup assembly-language
routine, configuration files, and associated
options.
compiler can optimize your program and
explains ways to control optimization.
tips on:
• Aliasing assumptions
• Alignment assumptions
• Volatile object
• Known problems
• C version incompatibilities
• Troubleshooting
13. MessagesDescribes the diagnostic messages that the
compiler produces.
1-5
1
i960 Processor Compiler User's Guide
Audience Description
This manual assumes that you are familiar with the i960 processor
architecture, C and assembly language programming, and your host
computer's operating system.
Licensing and Copyrights
Refer to the i960 Software Tools License Guide for licensing and copyright
statements.
UNIX and Windows Conventions
This manual tells you how to use the compiler in both UNIX and Windows
95/NT systems. This manual uses the following conventions:
• Command-lines appear without a preceding prompt.
• Paths use the UNIX forward slash (
backslash (
• Command-line option examples use the UNIX dash (
than the Windows forward slash (
• Environment variables are referenced using the UNIX dollar-sign
(e.g.,
\) for pathnames.
$I960BASE), not the Windows % character.
/) rather than the Windows
-) prefix rather
/) prefix.
1-6
NOTE. In UNIX, only the dash (-) is accepted as a prefix for a
command-line option. In Windows, both the (
as a prefix for a command-line option.
-) and the (/) are accepted
The CTOOLS Compilation System
Customer Service
If you need service or assistance with CTOOLS, see your Getting Started
with the i960 Processor Development Tools manual.
Where Do You Go From Here?
If you installed the CTOOLS GNU interface, go to Chapter 2 for
information on using the gcc960 compiler driver. If you installed the
CTOOLS/960 interface, go to Chapter 3 for information on using the
ic960 compiler driver. Once you are familiar with the compiler driver
interface, you are ready to read Chapters 4 through 6, where you learn
how to use some of the more advanced features of the compilation system,
including whole program optimizations, profiling, and using the gcdm
global decision maker program.
1
1-7
gcc960 Compiler Driver
This chapter describes how to use the gcc960 driver program to control the
compilation system. Topics include:
• running the compilation system
• sample command lines
• predefined macros
• command line options and their modifiers
Controlling the Compilation System with gcc960
gcc960-style translation and linking requires use of the gcc960 driver,
preprocessor, compiler, assembler, and linker.
2
The gcc960 compiler driver (
controls the preprocessor (
the compiler (
invoke the assembler, linker, and gcdm960 optimization decision maker.
Command-line options and environment variables allow you to control the
compilation.
gcc960 controls preprocessing, compilation, assembly and linking.
• Filenames ending in
compiled.
• Filenames ending in
compiled.
• Compiler output files plus any input files with names ending in
assembled.
• Input files with names ending in
then assembled. (UNIX only.)
cc1.exe in Windows, cc1.960 on Unix). It can also
gcc960.exe in Windows, gcc960 on Unix)
cpp.exe in Windows, cpp.960 on Unix) and
.c are taken as C source to be preprocessed and
.i are taken as preprocessor output to be
.s are
.S (uppercase) are preprocessed and
2-1
2
i960 Processor Compiler User's Guide
• The resulting object files, plus any other input files, are passed to the
linker to produce an executable.
• Program-wide and profile-directed optimizations can be performed
during the link step. For an overview of this capability, see Chapter 4.
Invoking the Compiler with gcc960
The gcc960 command-line syntax is:
gcc960 [-
option
]... [
path/]filename
... [@
response-file
]
gcc960
option
is the compiler driver executable filename.
is a compiler option. Case is significant in
options and their arguments. Multiple singlecharacter options cannot be grouped:
different from
options contradict each other, the right-most
option in the command line takes precedence.
For example, the following command line sets
the value of the symbol
gcc960 -DL=80 -DL=132 proto.c
Note that the gcc960 compiler driver does not
check the command line options for validity.
Invalid options are ignored without producing a
warning message.
On UNIX, the compiler recognizes a letter
preceded by a hyphen (
Windows, the compiler recognizes a letter
preceded by either a hyphen (
an option. For example,
Architecture option for UNIX or Windows.
However, on a Windows system,
specifies the architecture option.
-d -r. When two or more
L to 132:
-) as an option. In
-) or a slash (/) as
-A specifies the
-dr is
/A also
2-2
gcc960 Compiler Driver
2
path
NOTE. Although Windows pathnames require backslashes (\), this
manual shows paths using the forward slash required by UNIX (
filename
@
response-file
identifies the directory containing the file named
by
filename
filename
directory. Each
directory requires a separate
is the name of a source, preprocessed source,
assembly-language, or other file (e.g., linker
directive file) to be processed by the compilation
system. The gcc960 command line allows
specification of more than one
[
path/]filename
Open the named response file and read in its
contents as if they had been typed on the
command line. Response files are a convenient
way to store commonly-used command line
options, and a way to get around the 128character limit in Windows command lines.
. Not specifying
causes gcc960 to search in the current
filename
.
path
for a
not in the current
path
specification.
/
).
Response files can contain comments. Lines
whose first non-whitespace character is
treated as comment lines, and ignored.
# are
gcc960 Sample Command Lines
This section provides examples of how the compiler is commonly invoked.
All these examples assume that you have C source files named
t2.c and that you are generating code for the i960 CA architecture.
t1.c and
2-3
2
i960 Processor Compiler User's Guide
Preprocessing a Source File
To preprocess a source file, use the command:
gcc960 -E t1.c
-E
informs the compiler to preprocess the source
file and echo the output to stdout.
Generating Assembly Code
To generate assembly code for the i960 CA architecture, use the following
command.
gcc960 -S -ACA t1.c
-S
instructs the compiler to generate assembly code.
-A specifies the i960 CA architecture.
Generating an Object Module with Debug Information
To generate a object module with debug information, use the following
command.
gcc960 -c -g -ACA t1.c
2-4
-g
instructs the compiler to generate debug
information.
-c instructs the compiler to generate an object file.
Generating an Executable
To generate an absolute module (executable file) for a Cyclone board with
a CA processor, use the following command.
gcc960 -ACA -Tmcycx -g -O t1.c t2.c -o test
The above command compiles the modules t1.c and t2.c and links them
with appropriate libraries to generate an absolute module targeted for a
Cyclone i960 Cx evaluation board.
-Tmcycx instructs the compiler that you are targeting a
Cyclone i960 Cx evaluation board.
gcc960 Compiler Driver
-O causes the compiler to perform some basic
optimizations on the generated code.
-o instructs the compiler to name the generated
executable test.
gcc960 Linker Options
2
When you do not specify a target with the T
not attempt to link programs for a specific target board. Unless otherwise
specified,
following linker command is issued:
gld960 -AKB $G960BASE/lib/crt960.o
To link for a different target, you can change the crt (startup) file and add
board and monitor support libraries.
To link for another environment, the options
gcc960 from including the default C startup files or libraries in the link,
allowing them to be fully specified by the user. For example:
gcc960 -crt -nostdlib mycrt.o
You can invoke gcc960 to create object files in either the b.out, COFF or
ELF object module format. The compilation system accepts the
option to generate COFF and the Felf option to generate ELF; these
options override the gcc960 driver's default format option, which is
Fbout.
For more detailed information, see the following discussions of compiler
invocation and options.
.c and .s files are compiled and/or assembled, and the
target
file.
option, gcc960 does
file
.o... -lqf -lc -lm
crt and nostdlib prevent
o... -lc -lmylib
Fcoff
2-5
2
i960 Processor Compiler User's Guide
Table 2-1 lists the linker options that gcc960 passes directly to the linker.
Table 2-1Linker Options Accepted by gcc960
OptionNameDescription
eEntry pointdefines entry point other than default for
beginning execution of program.
gcdmDecision Maker invokes gcdm960 decision maker.
lArchive filespecifies an archive file as input.
LLibrary searchadds directories to search for libraries,
configuration files, and startup object files.
rRelocationretains relocation information in the output
object file.
sStripstrips line-number entries and symbol-table
entries from the linker's COFF output file.
uUnresolved
Symbol
introduces an unresolved symbol, causing the
linker to search symbol tables for resolution of
the reference.
2-6
X | xCompressX removes all symbols from the output symbol
table; x removes only local symbols.
yTrace symboltraces a symbol; indicates object files where it
appears; provides other information.
zTime stampsuppresses COFF time stamp in linker output
file.
gcc960 and Predefined Macros
Predefined macros within a program can act as constants during execution
or as values in conditional-compilation statements. Predefined macros
include ANSI-standard macros and macros specific to the i960 processor
architecture. The
macros but not ANSI-standard macros.
U (Undefine) option removes i960 processor-specific
gcc960 Compiler Driver
The following macros are available in accordance with the ANSI standard
for C, as described in the book, C: A Reference Manual:
__DATE__ __FILE__ __LINE__ __TIME__ __STDC__
The following macros are predefined by the compilation system when
invoked with the gcc960 driver program:
__GCC960_VERis defined to a decimal number that can be used
to check the version number of the compiler.
The number is expressed in decimal as
MmmPPPP
mm
is the minor version number, and
internal version number that is used to track the
patch level. So, for example, R5.0 patch level
4032 have
5004032.
__i960indicates the i960 processor environment. The
compiler defines
macro can be used to identify the parts of a
program specific to the i960 processor.
, where M is the major version number,
PPPP
is an
__GCC960_VER defined to be
__i960 automatically. This
2
__i960
__PICindicates that the generated code is position-
__PIDindicates that the generated data is position-
xx
indicates the i960 processor instruction set in
use. The compiler automatically defines the
__i960
CF, JA, JF, JD, HA, HD, HT, or RP. Definition of
xx
instruction set specified by the
option.
independent. The
(Generate-for-position-independent-code) option
causes the
independent. The
(Generate-for-position-independent-data) option
causes the
xx
macro. The xx is SA, SB, KA, KB, CA,
depends on the specific i960 processor
A (Architecture)
mpic
__PIC macro to be defined.
mpid
__PID macro to be defined.
2-7
2
i960 Processor Compiler User's Guide
__i960_BIG_ENDIAN__ indicates that the generated code is arranged for
__STRICT_ANSI__indicates that C constructs not conforming to the
__CHAR_UNSIGNED__indicates that the plain char type are treated like
gcc960 and File Use
The compiler, assembler, and linker all use filenames specified on the
gcc960 command line to find and create input and output files. In
addition, translation and linking require temporary work files.
Input Files
big-endian address space. The
option causes this macro to be defined.
ANSI standard should be flagged. The
(ANSI) option causes these macros to be
defined.
the
unsigned char type. This is the default.
G (Big-endian)
ansi
2-8
The gcc960 command line allows filename inputs that support
specification of assembly-language files, preprocessed source files, C
source files, object files, and libraries. The compiler driver determines the
type of each input file by the filename extension, as follows:
filename
filename
filename
filename
.cindicates a C source file that can contain macros
and preprocessor directives.
.iindicates a preprocessed C source file.
.sindicates an assembly-language source file.
.Sindicates an assembly-language source file that
can contain preprocessor macros and directives.
gcc960 Compiler Driver
The driver passes any other filename to the linker. The linker then
determines whether the file is an object file, library, or configuration file.
Input files not needed for processing are not processed. For example, if
you specify an assembly-language (
S (Assembly) compile into assembly code option, gcc960 takes no action
on the assembly-language file.
filename
.s) file and also specify the
Include Files
The gcc960 command line allows insertion of text from include files. The
#include preprocessor directive causes text insertion.
The I, I- and I. options affect the directories that are searched for the file
specified in the #include directive. These options are described in detail in
the Option Arguments and Syntax section. In the absence of the
gcc960 searches the current directory for #include “file” and
G960BASE/include directory for #include <file>.
I option,
Output Files
2
Specifying the options -E, -S, or -c causes the compilation system to
produce output of the last phase that completes for each primary input file.
Output can be preprocessed source, an assembly-language file, or an
unlinked object file. If no errors occur during processing, the output files
created by these options are usable as input to a future gcc960 invocation.
Table 2-2 lists the compilation phases and their inputs and outputs.
Specifying the
separate list file for each primary C source file. The list file is named by
replacing the .c or .I extension with .L.
Specifying the
for a make tool describing the dependencies of each source file. The
clist and -M options are described in detail in the Option Arguments
and Syntax section.
clist option generates a listing. gcc960 produces a
-M option causes the preprocessor to output rules suitable
2-9
2
i960 Processor Compiler User's Guide
Table 2-2Intermediate Inputs and Outputs
Last Phase
CompletedOptionInputsOutputs
preprocessing M, EC source filesdisplay on standard
When specifying only one primary input file, the o (Output) option names
a single output file. Specifying multiple primary input files, or not
specifying an output filename, causes gcc960 to use the primary input
filenames to derive corresponding default output filenames with the form
filename.e
filename
, where:
is the primary input filename without its
extension.
e
is a single-letter extension indicating the contents
of a file, as follows:
sindicates an assembly-language file
from the
oindicates an object file from the c
S option.
option.
Lindicates a listing file from the
clist option.
gcc960 Compiler Driver
Unless otherwise specified, the destination directory for any output file is
the current working directory. If
destination directory, the compilation system overwrites the existing file.
filename.e
already exists in the
2
.GLD Files
The filename
from the linker, in the absence of an Output option when the compilation
proceeds all the way to the link step. For ELF files, the default is
and for bout files, the default is b.out.
The following examples illustrate the creation and use of output filename
extensions:
• The command
produces the object files proto.o and proto1.o and the listing files
proto.L and proto1.L.
• The command
produces the object file proto_v1.o and the listing file proto.L.
• The command
executable file
The .GLD files provide a convenient mechanism for specifying default
options to the compiler and linker. It also provides a mechanism for
specifying the startup file and the libraries to be linked in. These files are
meant to be used with the gcc960 interface to the tools (GLD is an
acronym for gcc960 linker directive file even though it can be used to pass
options to the compiler as well).
a.out is the default for the executable COFF object file
e.out
gcc960-c-clist sproto.cproto1.i
gcc960-c-o proto_v1.o-clist s proto.c
gcc960-ACA -Tmcycxproto.c produces the
b.out.
By default, the installation program places several
directory [
Cyclone evaluation boards. To illustrate, the sample
below is tailored for the Cyclone i960 Cx processor-based evaluation
board.
$G960BASE]/lib. These files have been tailored to the
In the .GLD file, you can place any options that the tools accept on the
command line. For example, in the
see options for the gcc960 compiler driver and linker.
.GLD file shown in Example 2-1, you
The command in the
gcc960 compiler driver. This setting is then used throughout the
compilation process. The options following
fashion as if they were specified on the gcc960 invocation line.
The commands in the
component built into them so that options could be included in a
conditional fashion. These sections determine the startup code, linker
options and the libraries that are passed on to the linker.
The
crt: section is used to specify the startup code. In the example
given above, if the
line, then the compiler driver uses the following for the startup code.
[G960BASE]/lib/crt960_e.oif both -mpid and -G options are on
[G960BASE]/lib/crt960_p.oif -mpid option is on -G is off
[G960BASE]/lib/crt960_b.oif -mpid option is off and -G is on
[G960BASE]/lib/crt960.oif both -mpid and -G options are off
gcc: section defines the architecture setting for the
gcc: are treated in the same
crt:, ld:, and lib: sections have a conditional
-crt option has not been specified on the compile
2-12
Loading...
+ 317 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.