Intel i960 User Manual

0 (0)
i960 Processor 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
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
iii
i960 Processor Compiler User's Guide
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
iv
Contents
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
v
i960 Processor Compiler User's Guide
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
vi
Contents
#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
vii
i960 Processor Compiler User's Guide
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
viii
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
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
ix
i960 Processor Compiler User's Guide
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
x
Contents
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
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-1 Compiler Limits
Limit
Control structure nesting levels 15 Conditional compilation nesting levels 6 Declarator modifiers 12 Declaration parenthesis nesting levels 31 Parenthesis nesting levels 32 Significant characters for internal identifier 31 Name length for external identifier 6 Identifiers in a single block 127 Macros simultaneously defined 1024 Parameters per function call 31 Characters in a logical line 509 Characters in a string 509 Bytes in an object 32767 Include file nesting levels 8 Case labels in a switch 257 Members in one structure or union 127 Enumeration constants in one enumeration 127 Structure nesting levels 15 External identifiers per file 511 Parameters per macro 31
1
ANSI Minimum
1-3
1
i960 Processor Compiler User's Guide
About this Manual
This manual contains the following chapters:
Table 1-2 Chapter Descriptions
Chapter Number Title Description
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 command­line 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-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.
1
8. gcc960 / ic960 Compatibility
9. Position Independence and Reentrancy
10. Initializing the Execution Environment
11. Optimization Describes the different ways in which the
12. Caveats This chapter provides useful programming
Describes the incompatibilities between ic960 and gcc960.
Provides information on writing i960 processor applications that require position­independent 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. Messages Describes 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 single­character 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 128­character 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-1 Linker Options Accepted by gcc960
Option Name Description
e Entry point defines entry point other than default for
beginning execution of program.
gcdm Decision Maker invokes gcdm960 decision maker. l Archive file specifies an archive file as input. L Library search adds directories to search for libraries,
configuration files, and startup object files.
r Relocation retains relocation information in the output
object file.
s Strip strips line-number entries and symbol-table
entries from the linker's COFF output file.
u Unresolved
Symbol
introduces an unresolved symbol, causing the linker to search symbol tables for resolution of the reference.
2-6
X | x Compress X removes all symbols from the output symbol
table; x removes only local symbols.
y Trace symbol traces a symbol; indicates object files where it
appears; provides other information.
z Time stamp suppresses 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_VER is 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.
__i960 indicates 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
__PIC indicates that the generated code is position-
__PID indicates 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
.c indicates a C source file that can contain macros
and preprocessor directives.
.i indicates a preprocessed C source file. .s indicates an assembly-language source file. .S indicates 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-2 Intermediate Inputs and Outputs
Last Phase Completed Option Inputs Outputs
preprocessing M, E C source files display on standard
compilation S C source files
preprocessed files
assembly c C source files
preprocessed files assembly files
linking (default) C source files
preprocessed files assembly files unlinked object files relinkable object files libraries configuration files
output assembly-language file
listing files unlinked object files
listing files
list files executable file relinkable object file
2-10
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:
s indicates an assembly-language file
from the
o indicates an object file from the c
S option.
option.
L indicates 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 s proto.c proto1.i
gcc960 -c -o proto_v1.o -clist s proto.c
gcc960 -ACA -Tmcycx proto.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
.GLD files in the
.GLD file given
2-11
2
i960 Processor Compiler User's Guide
Example 2-1 Sample .gld File
gcc:-ACA
crt:%{!crt:%[~]/lib/%{mpid:%{G:crt960_e.o}%{!G:crt960_p.o}} %{!mpid:%{G:crt960_b.o}%{!G:crt960.o}}}
ld:%{!Ttext:-Ttext 0xA0008000}%{*: -defsym _heap_size=0x20000;_heap_base=(_end+0xf)&~0xf;_heap_end=_heap_base+_heap_size­1;_stackbase=(_heap_end+0x40)&~0x3f -defsym fpem_CA_AC=0x100}
lib:%{!nostdlib:-lmn -lll}
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.o if both -mpid and -G options are on [G960BASE]/lib/crt960_p.o if -mpid option is on -G is off [G960BASE]/lib/crt960_b.o if -mpid option is off and -G is on [G960BASE]/lib/crt960.o if 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