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
Other manuals for i960 Series
2
Table of contents
Other Intel Processor manuals

Intel
Intel 80386 Quick user guide

Intel
Intel Core 2 Duo Processor User manual

Intel
Intel 8008 User manual

Intel
Intel XScale Core User manual

Intel
Intel Centrino Pro User manual

Intel
Intel Xeon Guide

Intel
Intel ARCHITECTURE IA-32 User manual

Intel
Intel Q77M vPro Guide

Intel
Intel Pentium II Xeon Quick start guide

Intel
Intel iAPX 86/88 User manual

























