Intel i960 Series User manual

i960Processor Compiler
User's Guide
Order Number: 651230-002
Revision Revision History Date
-001 Original Issue. 02/96
-002 Revised for release 5.1 01/97

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.

Contents
iii
Chapter 1 The CTOOLS Compilation System
Features........................................................................1-1
Compatibility and Conformance to Standards....................1-2
About this Manual..............................................................1-4
Audience Description.....................................................1-6
Licensing and Copyrights..............................................1-6
UNIX and Windows Conventions...................................1-6
Customer Service...............................................................1-7
Where Do You Go From Here?..........................................1-7
Chapter 2 gcc960 Compiler Driver
Controlling the Compilation System with gcc960 ...............2-1
Invoking the Compiler with gcc960................................2-2
gcc960 Sample Command Lines...................................2-3
gcc960 Linker Options...................................................2-5
gcc960 and Predefined Macros.....................................2-6
gcc960 and File Use ..........................................................2-8
Input Files......................................................................2-8
Include Files..................................................................2-9
Output Files...................................................................2-9
.GLD Files..........................................................................2-11
gcc960 Options..................................................................2-13
Option Arguments and Syntax...........................................2-15

i960 Processor Compiler User's Guide
iv
Chapter 3 ic960 Compiler Driver
Controlling the Compilation System with ic960...................3-1
Invoking the Compiler with ic960...................................3-2
ic960 Sample Command Lines......................................3-3
ic960 Linker Options......................................................3-4
ic960 and Predefined Macros........................................3-6
ic960 and Environment Variables..................................3-8
ic960 and File Use .............................................................3-11
Input Files......................................................................3-11
Include Files ..................................................................3-11
Temporary Files.............................................................3-12
Output Files...................................................................3-12
ic960 Options.....................................................................3-15
Option Arguments and Syntax ...........................................3-17
Chapter 4 Program-wide Analysis and Optimization
Introduction ........................................................................4-1
Individual and Program-wide Optimizations...................4-1
About Profiling...............................................................4-2
Creating Program-wide and Module-local Optimizations....4-2
Specifying the Program Database Directory..................4-2
Compiling for Program-wide Optimization with the fdb
Option............................................................................4-3
Global Decision Making and Optimization Using the
gcdm Option..................................................................4-3
Selecting Modules for Optimization with Substitution
Specifications ................................................................4-4

Contents
v
Profiling Your Program.......................................................4-5
Compiling for Profile Instrumentation with -fprof............4-5
Collecting a Profile.........................................................4-5
Building Self-contained Profiles with gmpf960...............4-6
Using Profiles During Global Decision Making and
Optimization with -gcdm,iprof ........................................4-7
Obtaining Program Coverage Analysis with gcov960....4-7
Using make To Perform Program-wide Optimizations........4-7
Adapting Makefiles for Program-wide Optimization.......4-8
Using Makefiles with Program-wide Optimizations for
Common Development Tasks .......................................4-10
Runtime Support for Profile Collection...............................4-15
Profile Initialization.........................................................4-15
Chapter 5 Profile Data Merging and Data Format (gmpf960)
Merging Profile Data ..........................................................5-1
gmpf960 Invocation............................................................5-2
Profile Format Specification ...............................................5-4
Profile Data Structures ..................................................5-4
default.pf File Format.....................................................5-4
Creating a Runtime Report with gmpf960..........................5-6
Chapter 6 gcdm Decision Maker Option
gcdm Option Syntax...........................................................6-1
gcdm Option Arguments ....................................................6-2
Substitution Controls .....................................................6-2
Whole-program Optimization Option (Category 1).........6-3
Module-local Optimization Options (Category 2)...........6-3
Miscellaneous Substitution Options (Category 3)..........6-5
External Reference Controls .........................................6-7

i960 Processor Compiler User's Guide
vi
Inline Level Control........................................................6-7
Input Profile Control.......................................................6-8
Fast Memory Controls ...................................................6-8
Dryrun Control ...............................................................6-9
Report Controls .............................................................6-9
Module-set Specification....................................................6-13
Chapter 7 Language Implementation
Data Representation..........................................................7-1
Scalars...........................................................................7-1
Aggregates....................................................................7-4
Other Type Keywords....................................................7-14
Calling Conventions ...........................................................7-14
Definitions......................................................................7-15
Parameter Assignment to Registers..............................7-17
Argument Blocks ...........................................................7-17
Return Values................................................................7-18
Compiler Implementation...............................................7-18
Object Module Section Use................................................7-19
Pragmas.............................................................................7-20
#pragma align [for gcc960 driver]..................................7-20
#pragma align [for ic960, or for gcc960 with
ic960 option]..................................................................7-22
#pragma cave................................................................7-26
#pragma compress........................................................7-30
#pragma i960_align [for gcc960 and ic960]...................7-31
#pragma inline...............................................................7-31
#pragma interrupt..........................................................7-32
#pragma isr....................................................................7-34

Contents
vii
#pragma optimize..........................................................7-34
#pragma pack................................................................7-35
#pragma pure................................................................7-37
#pragma section............................................................7-38
#pragma system............................................................7-38
Language Extensions ........................................................7-39
Statements and Declarations Inside of Expressions .....7-40
Naming an Expression’s Type.......................................7-40
Referring to a Type with typeof......................................7-41
Generalized Lvalues......................................................7-42
Conditional Expressions with Omitted Middle
Operands.......................................................................7-44
Arrays of Length Zero....................................................7-44
Non-lvalue Arrays Can Have Subscripts........................7-45
Arithmetic on Pointers to void and Pointers to
Functions.......................................................................7-45
Non-constant Initializers................................................7-46
Constructor Expressions ...............................................7-46
Declaring Attributes of Functions...................................7-47
Inquiring about Alignment..............................................7-48
Inline Functions Are as Fast as Macros.........................7-48
Controlling Names Used in Assembly Code..................7-50
Specifying Registers for Local Variables.......................7-51
Alternate Keywords .......................................................7-51
Inline Assembly Language.................................................7-52
Introduction....................................................................7-52
Resource Usage............................................................7-52
asm Statements ............................................................7-53
asm Functions...............................................................7-70

i960 Processor Compiler User's Guide
viii
Chapter 8 gcc960/ic960 Compatibility
char and short Parameters............................................8-1
enum Variable Byte Count.............................................8-1
char Types.....................................................................8-2
Identifying Architectures ................................................8-2
#pragma align................................................................8-3
mic3.0-compat Option....................................................8-3
mic2.0-compat Option....................................................8-3
Chapter 9 Position Independence and Reentrancy
Position-independent Code and Data ................................9-1
Position-independent Data............................................9-1
Position-independent Code...........................................9-2
Example: Position-independent ROM Code.................9-3
Guidelines for Writing Relocatable Programs................9-5
Reentrant Functions...........................................................9-6
Designing Reentrant Functions .....................................9-6
Chapter 10 Initializing the Execution Environment
Startup Code......................................................................10-1
RAM-based Initialization................................................10-4
ROM-based Initialization................................................10-4
Linker Configuration Files...................................................10-5
RAM-based Configuration File.......................................10-6
ROM-based Configuration File ......................................10-6
Chapter 11 Optimization
Optimization Categories and Mechanisms.........................11-1
Constants and Expression Evaluation................................11-3
Common Sub-expression Elimination............................11-3
Constant Expression Evaluation (Constant Folding) .....11-4
Dead-code Elimination...................................................11-5
Identity Collapsing.........................................................11-5
Constant Propagation....................................................11-6

Contents
ix
Calls, Jumps, and Branches ..............................................11-9
Branch Optimizations ....................................................11-9
Branch Prediction..........................................................11-10
Identification of Leaf Functions......................................11-11
Inline Function Expansion .............................................11-11
Tail-call Elimination........................................................11-12
Loop Optimizations ............................................................11-14
Movement of Loop-invariant Code ................................11-14
Induction Variable Elimination.......................................11-14
Loop Unrolling...............................................................11-15
Memory Optimizations........................................................11-15
Global Alias Analysis.....................................................11-15
Variable Shadowing ......................................................11-16
Register Use ......................................................................11-16
Local Variable Promotion ..............................................11-17
Register Management...................................................11-17
Register Spilling.............................................................11-17
Instruction Selection and Sequencing................................11-18
Code Compression........................................................11-18
Code Scheduling...........................................................11-18
Specialized-instruction Selection...................................11-20
Program-level Optimization................................................11-20
Inter-module Function Inlining.......................................11-20
Superblock Formation ...................................................11-21
Profile-based Branch-prediction Bit Setting...................11-22
Chapter 12 Caveats
Aliasing Assumptions.........................................................12-1
Alignment Assumptions......................................................12-3
Volatile Objects..................................................................12-4
Known Problems Using the Compiler.................................12-6
Type Promotion.............................................................12-6
Prototype Scope............................................................12-6

i960 Processor Compiler User's Guide
x
longjmp and Volatile Data..............................................12-7
Incorrect debug information generated for arrays with
unspecified bounds........................................................12-7
C Version Incompatibilities.................................................12-8
String Constants Read-only...........................................12-8
No Macro Argument Substitution in Strings...................12-8
External Variables and Functions in Blocks...................12-8
Combining long with typedef Names .............................12-9
Using typedef Names in Function Parameters ..............12-9
Whitespace in Compound Assignment Operators.........12-9
Flagging Unterminated Character Constants.................12-10
Disguised varargs or stdarg Routines............................12-10
Troubleshooting .................................................................12-10
Undefined References...................................................12-10
C Interrupt Service Routine Failures..............................12-11
Preventing Structure Padding........................................12-12
Breakpoints Inside Interrupt Handlers ...........................12-15
Chapter 13 Messages
Messages on the Standard Error Device.......................13-2
Messages in the Listing File ..........................................13-3
Index
Figures 7-1 Natural Alignment......................................................7-8
7-2 User-constrained Alignment ......................................7-9
7-3 Optimal Natural Alignment of std_struct....................7-12
7-4 Backward-compatible Natural Alignment of
std_struct...................................................................7-13
7-5 #pragma noalign Alignment of std_struct..................7-13
7-6 #pragma align Alignment of std_struct......................7-14
9-1 Memory for Hypothetical Position-independent
Application.................................................................9-4
11-1 Superblock Formation Process..................................11-21

Contents
xi
Tables 1-1 Compiler Limits..........................................................1-3
1-2 Chapter Descriptions.................................................1-4
2-1 Linker Options Accepted by gcc960..........................2-6
2-2 Intermediate Inputs and Outputs...............................2-10
2-3 gcc960 Option Summary...........................................2-15
2-4 Mcore Supported Architectures.................................2-41
3-1 Linker Options Accepted by ic960.............................3-5
3-2 Intermediate Inputs and Outputs...............................3-13
3-3 ic960 Option Summary..............................................3-17
3-4 Gcore Supported Architecures..................................3-37
3-5 Stop-after Option Phases and Output.......................3-59
6-1 gcdm Option Arguments............................................6-1
7-1 Scalar Data Types.....................................................7-2
7-2 Example Offset Values..............................................7-36
7-3 Return Value Class Matching....................................7-75
7-4 Argument Category to Parameter Class Matching
and Coercion.............................................................7-75
7-5 C Data Types and asm Classes................................7-78
8-1 Architecture Macros and Compatibility......................8-2
11-1 Optimizations and O
level
Settings ............................11-2
11-2 Examples of Constant Expression Evaluation...........11-4
11-3 Examples of Identity Collapsing................................11-6

The CTOOLS Compilation System
1-1
1
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 functions written in i960 processor assembly language source
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.)

i960 Processor Compiler User's Guide
1-2
1
• 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 -mcore0-3 and -Gcore0-3
options. With these options, you can generate code that is compatible
with multiple i960 processor types. For more information, see
Chapters 2 and 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.
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
1-3
1
Table 1-1 Compiler Limits
Limit ANSI
Minimum
Tested
Minimum
Control structure nesting levels 15
128
Conditional compilation nesting levels 6
32
Declarator modifiers 12
32
Declaration parenthesis nesting levels 31
64
Parenthesis nesting levels 32
128
Significant characters for internal identifier 31
128
Name length for external identifier 6
33
Identifiers in a single block 127
1024
Macros simultaneously defined 1024
4096
Parameters per function call 31
128
Characters in a logical line 509
4096
Characters in a string 509
4096
Bytes in an object 32767
65535
Include file nesting levels 8
32
Case labels in a switch 257
1024
Members in one structure or union 127
512
Enumeration constants in one enumeration 127
512
Structure nesting levels 15
64
External identifiers per file 511
2048
Parameters per macro 31
128

i960 Processor Compiler User's Guide
1-4
1
About this Manual
This manual contains the following chapters:
Table 1-2 Chapter Descriptions
Chapter
Number Title Description
1. The CTOOLS
Compilation
System
Introduces the compiler and provides
information on using this manual.
2. gcc960 Compiler
Driver Teaches you how to use the gcc960
command-line interface and provides a
complete list of command line options.
3. ic960 Compiler
Driver Teaches you how to use the ic960 command-
line interface and provides a complete list of
command line options.
4. Program-wide
Analysis and
Optimization
Tells you how to use some of CTOOLS most
powerful optimization features:
• individual module optimizations
• program-wide optimizations
• run-time profiling
5. Profile Data
Merging and
Data Format
(gmpf960)
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.
6. gcdm Decision
Maker Option 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.
continued ☛

The CTOOLS Compilation System
1-5
1
Table 1-2 Chapter Descriptions (continued)
Chapter
Number Title Description
7. Language
Implementation Describes data representation, register use,
object file format use, and pragmas for
modifying code generation.
8. gcc960 / ic960
Compatibility Describes the incompatibilities between ic960
and gcc960.
9. Position
Independence
and Reentrancy
Provides information on writing i960
processor applications that require position-
independent or reentrant programs.
10. Initializing the
Execution
Environment
Describes the initialization process for the
i960 processor execution environment,
including the startup assembly-language
routine, configuration files, and associated
options.
11. Optimization Describes the different ways in which the
compiler can optimize your program and
explains ways to control optimization.
12. Caveats This chapter provides useful programming
tips on:
• Aliasing assumptions
• Alignment assumptions
• Volatile object
• Known problems
• C version incompatibilities
• Troubleshooting
13. Messages Describes the diagnostic messages that the
compiler produces.

i960 Processor Compiler User's Guide
1-6
1
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 (/) rather than the Windows
backslash (\) for pathnames.
• Command-line option examples use the UNIX dash (-) prefix rather
than the Windows forward slash (/) prefix.
• Environment variables are referenced using the UNIX dollar-sign
(e.g., $I960BASE), not the Windows %character.
NOTE. In UNIX, only the dash (-) is accepted as a prefix for a
command-line option. In Windows, both the (-) and the (/) are accepted
as a prefix for a command-line option.

The CTOOLS Compilation System
1-7
1
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.

gcc960 Compiler Driver
2-1
2
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.
The gcc960 compiler driver (gcc960.exe in Windows, gcc960 on Unix)
controls the preprocessor (cpp.exe in Windows, cpp.960 on Unix) and
the compiler (cc1.exe in Windows, cc1.960 on Unix). It can also
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 .c are taken as C source to be preprocessed and
compiled.
• Filenames ending in .i are taken as preprocessor output to be
compiled.
• Compiler output files plus any input files with names ending in .s are
assembled.
• Input files with names ending in .S (uppercase) are preprocessed and
then assembled. (UNIX only.)

i960 Processor Compiler User's Guide
2-2
2
• 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 is the compiler driver executable filename.
option
is a compiler option. Case is significant in
options and their arguments. Multiple single-
character options cannot be grouped: -dr is
different from -d -r. When two or more
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 Lto 132:
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 (-) as an option. In
Windows, the compiler recognizes a letter
preceded by either a hyphen (-) or a slash (/) as
an option. For example, -A specifies the
Architecture option for UNIX or Windows.
However, on a Windows system, /A also
specifies the architecture option.
Other manuals for i960 Series
2
Table of contents
Other Intel Processor manuals

Intel
Intel Pentium 4 Quick start guide

Intel
Intel Pentium II Xeon Quick start guide

Intel
Intel core i9 X series User manual

Intel
Intel XScale Core User manual

Intel
Intel Xeon Guide

Intel
Intel Centrino Pro User manual

Intel
Intel Q77M vPro Guide

Intel
Intel 80386 Quick user guide

Intel
Intel 80C186EB User manual

Intel
Intel core i7 X series User manual