Analog Devices, Inc. reserves the right to change this product without
prior notice. Information furnished by Analog Devices is believed to be
accurate and reliable. However, no responsibility is assumed by Analog
Devices for its use; nor for any infringement of patents or other rights of
third parties which may result from its use. No license is granted by implication or otherwise under the patent rights of Analog Devices, Inc.
Trademark and Service Mark Notice
The Analog Devices logo, SHARC, and VisualDSP++ are registered trademarks of Analog Devices, Inc.
All other brand and product names are trademarks or service marks of
their respective owners.
CONTENTS
PREFACE
Purpose of This Manual ............................................................. xxxi
The Stack Overflow Detection Facility ............................ 2-113
INDEX
xxxVisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
PREFACE
Thank you for purchasing Analog Devices, Inc. development software for
signal processing applications.
Purpose of This Manual
The VisualDSP++ 5.0 C/C++ Compiler Manual for SHARC Processors con-
tains information about the C/C++ compiler and its features designed for
use with SHARC® (ADSP-21xxx) processors. It includes syntax for command lines, switches, and language extensions. It leads you through the
process of using library routines and writing mixed C/C++/assembly code.
Intended Audience
The primary audience for this manual is a programmer who is familiar
with Analog Devices processors. This manual assumes that the audience
has a working knowledge of the SHARC architecture and instruction set
and the C/C++ programming languages.
Programmers who are unfamiliar with SHARC processors can use this
manual, but they should supplement it with other texts (such as the
appropriate hardware reference and programming reference manuals) that
describe their target architectures.
VisualDSP++ 5.0 C/C++ Compiler Manual xxxi
for SHARC Processors
Manual Contents
Manual Contents
This manual contains:
•Chapter 1, “Compiler”
Provides information on compiler options, language extensions and
C/C++/assembly interfacing
•Chapter 2, “Achieving Optimal Performance From C/C++ Source
Code”
Shows how to optimize compiler operation
What’s New in This Manual
This revision (1.5) of the manual documents changes/additions related to
the C/C++ compiler for VisualDSP++® 5.0 and subsequent updates (up
to update 9). Changes to this book from revision 1.4 include:
•64-bit integer support: The compiler now supports the 64-bit integer types long long and unsigned long long, with corresponding
support in the ISO/IEC C standard library functions.
•Embedded C Support: The compiler supports the fixed-point type
fract as a native type. Refer to “Using Native Fixed-Point Types”
on page 1-90 for more information.
•Improved compliance with ISO/IEC standards: The compiler has
optional support for a freestanding implementation of the
ISO/IEC 9899:1999 C standard (“C99”), and support for a freestanding implementation of the ISO/IEC14882:2003 C++
standard (“C++ 2003”). See “Language Standards Compliance” on
page 1-113 for more information.
xxxiiVisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Preface
•Stack overflow detection: The C runtime system detects when the
application exceeds the allocated stack space. For multi-threaded
applications, this facility requires RTOS support. For more information, see “Stack Overflow Detection” on page 2-111.
•Corrections of typographic errors and reported document errata
The VisualDSP++ 5.0 C/C++ Compiler Manual for SHARC Processors provides information on C/C++ compiler and its features and documents
support for all current SHARC processors. It does not describe C/C++
and DSP run-time libraries which are separated into a library reference
manual, VisualDSP++ 5.0 Run-Time Library Manual for SHARC Processors.
Technical or Customer Support
You can reach Analog Devices, Inc. Customer Support in the following
ways:
•Visit the Embedded Processing and DSP products Web site at
•Contact your Analog Devices, Inc. local sales office or authorized
distributor
VisualDSP++ 5.0 C/C++ Compiler Manual xxxiii
for SHARC Processors
Supported Processors
Supported Processors
The name “SHARC” refers to a family of Analog Devices, Inc. high-performance 32-bit floating-point digital signal processors that can be used in
speech, sound, graphics, and imaging applications. For a complete list of
processors supported by VisualDSP++ 5.0, refer to VisualDSP++ online
Help.
Product Information
Product information can be obtained from the Analog Devices Web site,
VisualDSP++ online Help system, and a technical library CD.
Analog Devices Web Site
The Analog Devices Web site, www.analog.com, provides information
about a broad range of products—analog integrated circuits, amplifiers,
converters, and digital signal processors.
To access a complete technical library for each processor family, go to
http://www.analog.com/processors/technical_library. The manuals
selection opens a list of current manuals related to the product as well as a
link to the previous revisions of the manuals. When locating your manual
title, note a possible errata check mark next to the title that leads to the
current correction report against the manual.
xxxivVisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Preface
Also note,
MyAnalog.com is a free feature of the Analog Devices Web site
that allows customization of a Web page to display only the latest information about products you are interested in. You can choose to receive
weekly e-mail notifications containing updates to the Web pages that meet
your interests, including documentation errata against all manuals.
MyAnalog.com provides access to books, application notes, data sheets,
code examples, and more.
Visit MyAnalog.com to sign up. If you are a registered user, just log on.
Your user name is your e-mail address.
VisualDSP++ Online Documentation
Online documentation comprises the VisualDSP++ Help system, software
tools manuals, hardware tools manuals, processor manuals, Dinkum
Abridged C++ library, and FLEXnet License Tools documentation. You
can search easily across the entire VisualDSP++ documentation set for any
topic of interest.
For easy printing, supplementary Portable Documentation Format (.pdf)
files for all manuals are provided on the VisualDSP++ installation CD.
Each documentation file type is described as follows.
File Description
.chmHelp system files and manuals in Microsoft help format
.htm or
.html
.pdfVisualDSP++ and processor manuals in PDF format. Viewing and printing the
Dinkum Abridged C++ library and FLEXnet license tools software
documentation. Viewing and printing the .html files requires a browser, such as
Internet Explorer 6.0 (or higher).
.pdf files requires a PDF reader, such as Adobe Acrobat Reader (4.0 or higher).
VisualDSP++ 5.0 C/C++ Compiler Manual xxxv
for SHARC Processors
Product Information
Technical Library CD
The technical library CD contains seminar materials, product highlights,
a selection guide, and documentation files of processor manuals, VisualDSP++ software manuals, and hardware tools manuals for the following
processor families: Blackfin®, SHARC, TigerSHARC®, ADSP-218x, and
ADSP-219x.
To order the technical library CD, go to http://www.analog.com/proces-
sors/technical_library
processor, click the request CD check mark, and fill out the order form.
Data sheets, which can be downloaded from the Analog Devices Web site,
change rapidly, and therefore are not included on the technical library
CD. Technical manuals change periodically. Check the Web site for the
latest manual revisions and associated documentation errata.
, navigate to the manuals page for your
EngineerZone
EngineerZone is a technical support forum from Analog Devices. It allows
you direct access to ADI technical support engineers. You can search
FAQs and technical information to get quick answers to your embedded
processing and DSP design questions.
Use EngineerZone to connect with other DSP developers who face similar
design challenges. You can also use this open forum to share knowledge
and collaborate with the ADI support team and your peers. Visit
http://ez.analog.com to sign up.
xxxviVisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Preface
Social Networking Web Sites
You can now follow Analog Devices SHARC development on Twitter and
LinkedIn. To access:
•Twitter: http://twitter.com/ADISHARC
•LinkedIn: Network with the LinkedIn group, Analog Devices
SHARC:
http://www.linkedin.com
Notation Conventions
Text conventions used in this manual are identified and described as
follows.
ExampleDescription
Close command
(File menu)
{this | that}Alternative required items in syntax descriptions appear within curly
[this | that]Optional items in syntax descriptions appear within brackets and sepa-
[this,…]Optional item lists in syntax descriptions appear within brackets delim-
.
filenameNon-keyword placeholders appear in text with italic style format.
appear throughout this document.
Titles in in bold style reference sections indicate the location of an item
within the VisualDSP++ environment’s menu system (for example, the
Close command appears on the File menu).
brackets and separated by vertical bars; read the example as
that. One or the other is required.
rated by vertical bars; read the example as an optional
ited by commas and terminated with an ellipse; read the example as an
optional comma-separated list of
SECTIONCommands, directives, keywords, and feature names are in text with
letter gothic font.
this.
this or
this or that.
Additional conventions, which apply only to specific chapters, may
VisualDSP++ 5.0 C/C++ Compiler Manual xxxvii
for SHARC Processors
Notation Conventions
ExampleDescription
Note: For correct operation, ...
A Note provides supplementary information on a related topic. In the
online version of this book, the word Note appears instead of this
symbol.
Caution: Incorrect device operation may result if ...
Caution: Device damage may result if ...
A Caution identifies conditions or inappropriate usage of the product
that could lead to undesirable results or product damage. In the online
version of this book, the word Caution appears instead of this symbol.
War ni ng : Injury to device users may result if ...
A Warning identifies conditions or inappropriate usage of the product
that could lead to conditions that are potentially hazardous for devices
users. In the online version of this book, the word War ni ng appears
instead of this symbol.
xxxviiiVisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
1COMPILER
The C/C++ compiler (cc21k) is part of Analog Devices development software for SHARC (ADSP-21xxx) processors.
This chapter contains:
The code examples in this manual have been compiled using
VisualDSP++ 5.0. The examples compiled with other versions of
VisualDSP++ may result in build errors or different output
although the highlighted algorithms stand and should continue to
stand in future releases of VisualDSP++.
•“C/C++ Compiler Overview” on page 1-3
provides an overview of C/C++ compiler for SHARC processors.
•“Compiler Command-Line Interface” on page 1-5
describes the operation of the compiler as it processes programs,
including input and output files, and command-line switches.
•“Using Native Fixed-Point Types” on page 1-90
describes the compiler’s support for the native fixed-point type
fract, defined in Chapter 4 of the “Extensions to support embedded
•“Language Standards Compliance” on page 1-113
describes how to enable the best possible compliance to either the
ISO/IEC 9899:1990 C standard, the ISO/IEC 9899:1999 C standard or the ISO/IEC 14882:2003 C++ standard.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-1
for SHARC Processors
•“MISRA-C Compiler” on page 1-115
describes how the
cc21k compiler enables checking for MISRA-C:
2004 Guidelines.
•“C/C++ Compiler Language Extensions” on page 1-128
describes the cc21k compiler’s extensions to the ISO/ANSI standard for the C and C++ languages.
•“Preprocessor Features” on page 1-289
contains information on the preprocessor and ways to modify
source compilation.
•“C/C++ Run-Time Model and Environment” on page 1-300
contains reference information about implementation of C/C++
programs, data, and function calls in ADSP-21xxx processors.
•“C/C++ and Assembly Interface” on page 1-347
describes how to call an assembly language subroutine from a
C/C++ program, and how to call a C/C++ function from within an
assembly language program.
•“Compiler C++ Template Support” on page 1-381
describes how templates are instantiated at compile time
•“File Attributes” on page 1-387
describes how file attributes help with the placement of runtime
library functions.
1-2VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
C/C++ Compiler Overview
The C/C++ compiler (cc21k) is designed to aid your project development
efforts by:
•Processing C and C++ source files, producing machine-level versions of the source code and object files
•Providing relocatable code and debugging information within the
object files
•Providing relocatable data and program memory segments for
placement by the linker in the processors’ memory
Using C/C++, developers can significantly decrease time-to-market since
it gives them the ability to efficiently work with complex signal processing
data types. It also allows them to take advantage of specialized processor
operations without having to understand the underlying processor
architecture.
The C/C++ compiler (cc21k) compiles ISO/ANSI standard C and C++
code for the SHARC processors. Additionally, Analog Devices includes
within the compiler a number of C language extensions designed to assist
in processor development. The compiler runs from the VisualDSP++ environment or from an operating system command line.
The C/C++ compiler (cc21k) processes your C and C++ language source
files and produces SHARC assembler source files. The assembler source
files are assembled by the SHARC assembler (
creates Executable and Linkable Format (ELF) object files that can either
be linked (using the linker) to create an ADSP-21xxx executable file or
included in an archive library (elfar). The way in which the compiler
controls the assemble, link, and archive phases of the process depends on
the source input files and the compiler options used.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-3
for SHARC Processors
easm21k). The assembler
C/C++ Compiler Overview
Your source files contain the C/C++ program to be processed by the compiler. The
cc21k compiler supports the following standards, each with
Analog Devices extensions enabled:
•A hosted implementation of the ISO/IEC 9899:1990 C standard
(C89).
•A freestanding implementation of the ISO/IEC 9899:1999 C standard (C99).
•A freestanding implementation of the ISO/IEC 14882:2003 C++
standard (C++ 2003).
RTTI and Exceptions for C++ are supported, but disabled by default. See
information on these switches: “-rtti” on page 1-76 and “-eh” on
page 1-29.
For information on the C language standard, see any of the many reference texts on the C language. Analog Devices recommends the Bjarne
Stroustrup text “The C++ Programming Language” from Addison Wesley
Longman Publishing Co (ISBN: 0201889544) (1997) as a reference text
for the C++ programming language.
The cc21k compiler supports a set of C/C++ language extensions. These
extensions support hardware features of the ADSP-21xxx processors. For
information on these extensions, see “C/C++ Compiler Language Exten-
sions” on page 1-128.
You can set the compiler options from the Compile page of the Project Options dialog box of the VisualDSP++ Integrated Development and
Debug Environment (IDDE). These selections control how the compiler
processes your source files, letting you select features that include the language dialect, error reporting, and debugger output.
For more information on the VisualDSP++ environment, see the
VisualDSP++ 5.0 User’s Guide and online Help.
1-4VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
Compiler Command-Line Interface
This section describes how the cc21k compiler is invoked from the command line, the various types of files used by and generated from the
compiler, and the switches used to tailor the compiler’s operation.
This section contains:
•“Running the Compiler” on page 1-6
•“Compiler Command-Line Switches” on page 1-7
•“Environment Variables Used by the Compiler” on page 1-77
•“Data Type and Data Type Sizes” on page 1-78
•“Optimization Control” on page 1-81
•“Controlling Silicon Revision and Anomaly Workarounds Within
the Compiler” on page 1-86
By default, the compiler runs with Analog Devices extension keywords for
C code enabled. This means that the compiler processes source files written in ISO/IEC 9899:1989 standard C language supplemented with
Analog Devices extensions. Table 1-2 on page 1-7 lists the switches that
select the language dialect.
Although many switches are generic between C and C++, some of them
are valid in C++ mode only. A summary of the generic C/C++ compiler
switches appears in Table 1-3 on page 1-8. A summary of the C++-specific
compiler switches appears in Table 1-5 on page 1-19. The summaries are
followed by descriptions of each switch.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-5
for SHARC Processors
When developing a project, sometimes it is useful to modify the
compiler’s default options settings. The way the compiler’s options
are set depends on the environment used to run the processor
development software.
Compiler Command-Line Interface
Running the Compiler
Use the following syntax for the cc21k command line:
cc21kName of the compiler program for SHARC processors.
-switchSwitch (or switches) to process.
sourceFileName of the file to be preprocessed, compiled, assembled, and/or linked
Description
The compiler has many switches. These switches select the operations and
modes for the compiler and other tools. Command-line switches are case
sensitive. For example,
-O is not the same as -o.
When file names or other switches for the compiler include spaces
or other special characters, you must ensure that these are properly
quoted (usually using double-quote characters), to ensure that they
are not interpreted by the operating system before being passed to
the compiler.
The sourceFile element (the name of the source file to be processed) can
include the drive, directory, file name and file extension. The compiler
supports both Win32 and POSIX-style paths by using forward or back
slashes as the directory delimiter. It also supports UNC path names (starting with two slashes and a network name). If the name contains spaces,
enclose it in straight quotes; for example, "long file name.c"
1-6VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
Compiler Command-Line Switches
This section describes the command-line switches used when compiling.
It contains a set of tables that provide a brief description of each switch.
These tables are organized by type of switch. Following these tables are
sections that provide fuller descriptions of each switch.
C/C++ Compiler Switch Summaries
This section contains a set of tables that summarize generic and specific
switches (options).
•“C/C++ Mode Selection Switches”, Table 1-2 on page 1-7
•“C/C++ Compiler Common Switches”, Table 1-3 on page 1-8
•“C Mode (MISRA) Compiler Switches”, Table 1-4 on page 1-18
•“C++ Mode Compiler Switches”, Table 1-5 on page 1-19
A brief description of each switch follows the tables, beginning
on page 1-20.
Table 1-2. C/C++ Mode Selection Switches
Switch NameDescription
-c89
(on page 1-20)
-c99
(on page 1-20)
-c++
(on page 1-20)
Supports programs that conform to the
ISO/IEC 9899:1990 standard. This is the
default mode.
Supports programs that conform to the
ISO/IEC 9899:1999 standard.
Supports ISO/IEC 1482:2003 standard C++
with Analog Devices extensions. Note that C++
is not supported on the ADSP-21020 processor.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-7
for SHARC Processors
Compiler Command-Line Interface
Table 1-3. C/C++ Compiler Common Switches
Switch NameDescription
sourcefile
(on page 1-21)
-@ filename
(on page 1-21)
Specifies file to be compiled
Reads command-line input from the file
-A name[tokens]
(on page 1-21)
-add-debug-libpaths
(on page 1-22)
-aligned-stack
(on page 1-23)
-alttok
(on page 1-23)
-always-inline
(on page 1-24)
-annotate
(on page 1-24)
-annotate-loop-instr
(on page 1-24)
-auto-attrs
(on page 1-25)
-build-lib
(on page 1-25)
-C
(on page 1-25)
-c
(on page 1-25)
-compatible-pm-dm
(on page 1-25)
Asserts the specified name as a predicate
Link against debug-specific variants of system libraries,
where available
Aligns the program stack on a double-word boundary
Allows alternative keywords and sequences in sources
Tr e a ts
inline keyword as a requirement rather than a
suggestion
Annotates compiler-produced assembly files
Provides additional annotation information for the
prolog, kernel and epilog of a loop
Directs the compiler to emit automatic attributes
based on the files it compiles. Enabled by default.
Directs the librarian to build a library file
Retains preprocessor comments in the output file;
must run with the -E or -P switch
Compiles and/or assembles only, but does not link
Specifies that the compiler shall treat
dm- and pm-qual-
ified pointers as assignment-compatible
-const-read-write
(on page 1-25)
-const-strings
(on page 1-26)
Specifies that data accessed via a pointer to
may be modified elsewhere
Directs the compiler to mark string literals as
const-qualified
const data
1-8VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch NameDescription
-D macro[=definition]
(on page 1-26)
-debug-types
(on page 1-26)
-double-size [-32|-64]
(on page 1-27)
Defines a macro
Supports building a *.h file directly and writing a
complete set of debugging information for the header
file
Selects 32- or 64-bit IEEE format for double.
The -double-size-32 is the default mode.
Compiler
-double-size-any
(on page 1-28)
-dry
(on page 1-28)
-dryrun
(on page 1-28)
-E
(on page 1-29)
-ED
(on page 1-29)
-EE
(on page 1-29)
-eh
(on page 1-29)
-enum-is-int
(on page 1-30)
-extra-keywords
(on page 1-30)
-file-attr name[=value]
(on page 1-31)
-flags-{tools} <arg1> [,arg2...]
(on page 1-31)
-float-to-int
(on page 1-32)
Indicates that the resulting object can be linked with
objects built with any double size
Displays, but does not perform, main driver actions
(verbose dry-run)
Displays, but does not perform, top-level driver
actions (terse dry-run)
Preprocesses, but does not compile, the source file
Preprocesses and sends all output to a file
Preprocesses and compiles the source file
Enables exception handling
By default
option ensures the
enums can have a type larger than int. This
enum type is int.
Recognizes ADI extensions to ANSI/ISO standards for
C and C++ (default mode)
Adds the specified attribute name/value pair to the
file(s) being compiled
Passes command-line switches through the compiler to
other build tools
Uses a support library function to convert a float to
integer
an
VisualDSP++ 5.0 C/C++ Compiler Manual 1-9
for SHARC Processors
Compiler Command-Line Interface
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch NameDescription
-force-circbuf
(on page 1-32)
-fp-associative
(on page 1-32)
Treats array references of the form
cular buffer operations
Treats floating-point multiply and addition as an associative
array[i%n] as cir-
-full-version
(on page 1-32)
-fx-contract
(on page 1-33)
-fx-rounding-mode-biased
(on page 1-33)
-fx-rounding-mode-truncation
(on page 1-33)
-fx-rounding-mode-unbiased
(on page 1-33)
-g
(on page 1-33)
-glite
(on page 1-34)
-H
(on page 1-34)
-HH
(on page 1-35)
-h[elp]
(on page 1-35)
Displays the version number of the driver and any processes invoked by the driver
Sets the default mode of
FX_CONTRACT to ON.
Sets the default mode of FX_ROUNDING_MODE to
BIASED.
Sets the default mode of FX_ROUNDING_MODE to
TRUNCATION.
Sets the default mode of
UNBIASED.
FX_ROUNDING_MODE to
Generates DWARF-2 debug information
Generates lightweight DWARF-2 debug information
Outputs a list of included header files, but does not
compile
Outputs a list of included header files and compiles
Outputs a list of command-line switches
-I directory
Appends directory to the standard search path
(on page 1-35)
-I-
(on page 1-36)
Establishes the point in the
include directory list at
which the search for header files enclosed in angle
brackets should begin
-i
(on page 1-36)
Outputs only header details or makefile dependencies
for include files specified in double quotes
1-10VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch NameDescription
-implicit-pointers
(on page 1-36)
-include filename
(on page 1-37)
-ipa
(on page 1-37)
Demotes incompatible-pointer-type errors into discretionary warnings. Not valid when compiling in C++
mode.
Includes named file prior to preprocessing each source
file
Enables interprocedural analysis
Compiler
-L directory
(on page 1-38)
-l library
(on page 1-38)
-list-workarounds
(on page 1-39)
-M
(on page 1-39)
-MD
(on page 1-39)
-MM
(on page 1-39)
-Mo filename
(on page 1-40)
-Mt filename
(on page 1-40)
-map filename
(on page 1-40)
-mem
(on page 1-40)
Appends directory to the standard library search path
Searches library for functions when linking
Lists all compiler-supported errata workarounds
Generates make rules only, but does not compile
Generates
make rules, compiles, and prints to a file
Generates make rules and compiles
Writes dependency information to
switch is used in conjunction with the
filename. This
-ED or -MD
options
Makes dependencies, where the target is renamed as
filename
Directs the linker to generate a memory map of all
symbols
Enables memory initialization
-misra
(on page 1-70)
(C compiler switch): Enables checking for MISRA-C:
2004 Guidelines, allows some relaxation of interpretation
VisualDSP++ 5.0 C/C++ Compiler Manual 1-11
for SHARC Processors
Compiler Command-Line Interface
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch NameDescription
-multiline
(on page 1-40)
-never-inline
(on page 1-41)
Enables string literals over multiple lines (default)
Ignores inline keyword on function definitions
-no-aligned-stack
(on page 1-41)
-no-alttok
(on page 1-41)
-no-annotate
(on page 1-41)
-no-annotate-loop-instr
(on page 1-42)
-no-auto-attrs
(on page 1-42)
-no-builtin
(on page 1-42)
-no-circbuf
(on page 1-43)
-no-db
(on page 1-43)
-no-defs
(on page 1-43)
-no-eh
(on page 1-43)
Does not double-word align the program stack
Does not allow alternative keywords and sequences in
sources
Disables the annotation of assembly files
Disables the production of additional loop annotation
information by the compiler (default mode)
Directs the compiler not to emit automatic attributes
based on the files it compiles
Recognizes only built-in functions that begin with two
underscores(
__)
Disables the automatic generation of circular buffer
code by the compiler
Specifies that the compiler shall not generate code containing delayed branches jumps
Disables preprocessor definitions: macros, include
directories, library directories, run-time headers, or
keyword extensions
Disables exception handling
-no-extra-keywords
(on page 1-44)
-no-fp-associative
(on page 1-44)
-no-fx-contract
Does not accept ADI keyword extensions that might
affect ISO/ANSI standards for C and C++
Does not treat floating-point multiply and addition as
an associative
Sets the default mode of
FX_CONTRACT to OFF.
(on page 1-44)
1-12VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch NameDescription
-no-mem
(on page 1-45)
Disables memory initialization
Compiler
-no-multiline
(on page 1-45)
-no-progress-rep-timeout
(on page 1-45)
-no-sat-associative
(on page 1-45)
-no-saturation
(on page 1-46)
-no-shift-to-add
(on page 1-46)
-no-simd
(on page 1-46)
-no-std-ass
(on page 1-47)
-no-std-def
(on page 1-47)
-no-std-inc
(on page 1-47)
-no-std-lib
(on page 1-47)
Disables multiple line string literal support
Prevents the compiler from issuing a diagnostic during
excessively long compilations
Saturating addition is not associative.
Causes the compiler not to introduce saturation
semantics when optimizing expressions
Disables automatic SIMD mode when compiling for
ADSP-211xx, ADSP-212xx, ADSP-213xx or
ADSP-214xx processors
Disables automatic SIMD mode when compiling for
ADSP-211xx, ADSP-212xx, ADSP-213xx or
ADSP-214xx processors
Disables any predefined assertions and system-specific
macro definitions
Disables preprocessor definitions and ADI keyword
extensions that do not have leading underscores(__)
Searches for preprocessor include header files only in
the current directory and in directories specified with
the -I switch
Searches for libraries only in directories specified with
the
-L switch
-no-threads
(on page 1-47)
-no-workaround workaround_id
(on page 1-48)
-normal-word-code
(on page 1-48)
Specifies that all compiled code need not be
thread-safe
Disables specific hardware anomaly workarounds
within the compiler
Directs the compiler to generate instructions of
normal-word size (48-bits)
VisualDSP++ 5.0 C/C++ Compiler Manual 1-13
for SHARC Processors
Compiler Command-Line Interface
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch NameDescription
-nwc
(on page 1-48)
-O [0|1]
(on page 1-48)
Has the same effect as compiling with the
-normal-word-code switch
Enables code optimizations
-Oa
(on page 1-49)
-Og
(on page 1-49)
-Os
(on page 1-49)
-Ov num
(on page 1-49)
-o filename
(on page 1-51)
-overlay
(on page 1-52)
-overlay-clobbers regs
(on page 1-52)
-P
(on page 1-53)
-PP
(on page 1-53)
-path-{asm|compiler|lib|link}
pathname
(on page 1-53)
-path-install directory
on page 1-53)
(
Enables automatic function inlining
Enables a compiler mode that performs optimizations
while still preserving the debugging information
Optimizes for code size
Controls speed versus size optimizations
Specifies the output file name
Disables the propagation of register information
between functions and forces the compiler to assume
that all functions clobber all scratch registers
Specifies the registers assumed to be clobbered by an
overlay manager
Preprocesses, but does not compile, the source file;
omits line numbers in the preprocessor output
Similar to
-P, but does not halt compilation after pre-
processing
Uses the specified directory as the location of the specified compilation tool (assembler, compiler, librarian,
or linker, respectively)
Uses the specified directory as the location of all compilation tools
-path-output directory
(
on page 1-54)
Specifies the location of non-temporary files
1-14VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch NameDescription
-path-temp directory
(on page 1-54)
-pch
(on page 1-54)
Specifies the location of temporary files
Generates and uses precompiled header files (*.pch)
Compiler
-pchdir directory
(on page 1-54)
-pgo-session
(on page 1-54)
-pguide
(on page 1-55)
-pplist filename
(on page 1-55)
-proc processor
(on page 1-56)
-progress-rep-func
(on page 1-57)
-progress-rep-opt
(on page 1-57)
-progress-rep-timeout
(on page 1-57)
-progress-rep-timeout-secs secs
(on page 1-57)
-R directory
(on page 1-57)
Specifies the location of PCHRepository
Specifies PGO session identifier; used with profile-guided optimization
Adds instrumentation for the gathering of a profile as
the first stage of performing profile-guided optimization
Outputs a raw preprocessed listing to the specified file
Specifies that the compiler should produce code suitable for the specified processor
Issues a diagnostic message each time the compiler
starts compiling a new function. Equivalent to
-Wwarn=cc1472.
Issues a diagnostic message each time the compiler
starts a new generic optimization pass on the current
function. Equivalent to -Wwarn=cc1473.
Issues a diagnostic message if the compiler exceeds a
time limit during compilation
Specifies how many seconds must elapse during a compilation before the compiler issues a diagnostic on the
length of compilation
Appends directory to the standard search path for
source files
-R-
(on page 1-58)
-reserve <reg1>[,reg2...]
(on page 1-58)
Removes all directories from the standard search path
for source files
Reserves certain registers from compiler use.
Note: Reserving registers can have a detrimental effect
on the compiler’s optimization capabilities.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-15
for SHARC Processors
Compiler Command-Line Interface
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch NameDescription
-restrict-hardware-loops maximum
(on page 1-59)
-S
(on page 1-59)
Restrict the number of levels of loop nesting used by
the compiler
Stops compilation before running the assembler
-s
(on page 1-59)
-sat-associative
(on page 1-59)
-save-temps
(on page 1-59)
-section id=section_name
(on page 1-60)
-short-word-code
(on page 1-61)
-show
(on page 1-61)
-si-revision version
(on page 1-61)
-signed-bitfield
(on page 1-62)
-structs-do-not-overlap
(on page 1-62)
-swc
(on page 1-63)
-syntax-only
(on page 1-63)
-sysdefs
(on page 1-63)
Removes debug info from the output executable file
Saturating addition is associative
Saves intermediate files
Orders the compiler to place data/program of type
“id” into the section “section_name”
Directs the compiler to generate instructions of short
word size (16/32/48-bits)
Displays the driver command-line information
Specifies a silicon revision of the specified processor.
The default setting is the latest silicon revision.
Makes the default type for
int bit-fields signed
Specifies that struct copies may use “memcpy” semantics, rather than the usual “memmove” behavior
Directs the compiler to generate instructions of short
word size (16/32/48-bits)
Checks the source code for compiler syntax errors, but
does not write any output
Defines the system definition macros
-T filename
Specifies the Linker Description File
(on page 1-63)
1-16VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch NameDescription
-threads
(on page 1-64)
-time
(on page 1-64)
Specifies that support for multithreaded applications is
to be enabled
Displays the elapsed time as part of the output information on each part of the compilation process
Compiler
-Umacro
(on page 1-64)
-unsigned-bitfield
(on page 1-65)
-v
(on page 1-65)
-verbose
(on page 1-66)
-version
(on page 1-66)
-W{error|remark|
suppress|warn} number
(on page 1-66)
-Werror-limit number
(on page 1-67)
-Werror-warnings
(on page 1-67)
-Wremarks
(on page 1-67)
-Wterse
(on page 1-67)
Undefines macro(s)
Makes the default type for plain
int bit-fields
unsigned
Displays both the version and command-line information
Displays command-line information
Displays version information
Overrides the default severity of the specified error
message
Stops compiling after reaching the specified number of
errors
Directs the compiler to treat all warnings as errors
Indicates that the compiler may issue remarks, which
are diagnostic messages even milder than warnings
Issues only the briefest form of compiler warning,
errors, and remarks
-w
Does not display compiler warning messages
(on page 1-67)
-warn-protos
(on page 1-68)
-workaround workaround_id
(on page 1-68)
Produces a warnings when a function is called without
a prototype
Enables code generator workaround for specific hardware errata
VisualDSP++ 5.0 C/C++ Compiler Manual 1-17
for SHARC Processors
Compiler Command-Line Interface
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch NameDescription
-write-files
(on page 1-68)
-write-opts
(on page 1-69)
Enables compiler I/O redirection
Passes the user options (but not input filenames) via a
temporary file
-xref filename
(on page 1-69)
Outputs cross-reference information to the specified
file
Table 1-4. C Mode (MISRA) Compiler Switches
Switch NameDescription
-misra
(on page 1-70)
-misra-linkdir
(on page 1-70)
-misra-no-cross-module
(on page 1-70)
-misra-no-runtime
(on page 1-71)
-misra-strict
(on page 1-71)
-misra-suppress-advisory
(on page 1-71)
-misra-testing
(on page 1-71)
-Wmis_suppress
(on page 1-71)
Enables checking for MISRA-C: 2004 Guidelines, allows some
relaxation of interpretation
Specifies directory for generation of .misra files.
If this option is not specified, a local directory called MIS-
RARepository is created.
Enables checking for MISRA-C: 2004 Guidelines, allows some
relaxation of interpretation. Does not generate .misra files to
check for link-time rule violations.
Enables checking for MISRA-C: 2004 Guidelines, allows some
relaxation of interpretation. Does not generate extra code to
perform run-time checking in support of a number of Rules.
Enables checking for MISRA-C: 2004 Guidelines
Enables checking for MISRA-C: 2004 Guidelines. Advisory
rules are not reported.
Enables checking for MISRA-C: 2004 Guidelines. Suppresses
reporting of MISRA-C rule 20.4, 20.7, 20.8, 20.9, 20.10,
20.11 and 20.12.
Overrides the default severity of the specified messages relating
to the specified MISRA-C rules
-Wmis_warn
(on page 1-72)
Overrides the default severity of the specified messages relating
to the specified MISRA-C rules
1-18VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Table 1-5. C++ Mode Compiler Switches
Switch NameDescription
-anach
(on page 1-72)
-check-init-order
(on page 1-73)
Supports some language features (anachronisms) that are prohibited by the C++ standard but still in common use
Adds run-time checking to the generated code highlighting potential uninitialized external objects.
Compiler
-extern-inline
(on page 1-74)
-friend-injection
(on page 1-74)
-full-dependencyinclusion
(on page 1-74)
-ignore-std
(on page 1-75)
-no-anach
(on page 1-75)
-no-extern-inline
(on page 1-75)
-no-friend-injection
(on page 1-76)
-no-implicit-inclusion
(on page 1-76)
-no-rtti
(on page 1-76)
-no-std-templates
(on page 1-76)
-rtti
(on page 1-76)
-std-templates
(on page 1-77)
Allows standard behavior with respect to extern inline functions
Allows non-standard behavior with respect to friend declarations.
When friend names are not injected, function names are visible
only when using argument-dependent lookup
Ensures re-inclusion of implicitly included files when generating
dependency information
Disables namespace
std within the C++ Standard header files.
Disallows the use of anachronisms that are prohibited by the C++
standard
Treats extern inline functions as though they have static linkage
Allows standard behavior. Friend function names are visible only
when using argument-dependent lookup. Friend class names are
never visible
Prevents implicit inclusion of source files as a method of finding
definitions of template entities to be instantiated
Disables run-time type information
Disables the lookup of names used in templates
Enables run-time type information
Enables the lookup of names used in templates
VisualDSP++ 5.0 C/C++ Compiler Manual 1-19
for SHARC Processors
Compiler Command-Line Interface
C/C++ Mode Selection Switch Descriptions
The following command-line switches provide C/C++ mode selection.
-c89
The -c89 switch directs the compiler to support programs that conform to
the ISO/IEC 9899:1990 standard. For greater conformance to the standard, the following switches should be used: -alttok, -const-read-write,
and -no-extra-keywords. (See Table 1-3 on page 1-8.)
-c99
The -c99 switch directs the compiler to support programs that conform to
a freestanding implementation of the ISO/IEC 9899:1999 standard. For
greater conformance to the standard, the following switches should be
used: -alttok, -const-read-write, and -no-extra-keywords. (See
Table 1-3 on page 1-8.)
-c++
The -c++ (C++ mode) switch directs the compiler to compile the source
file(s) written in ISO/IEC 1482:2003 standard C++ with Analog Devices
language extensions. When using this switch, source files with an extension of
All the standard features of C++ are accepted in the default mode except
exception handling and run-time type identification because these impose
a run-time overhead that is not desirable for all embedded programs. Support for these features can be enabled with the -eh and -rtti switches.
(See Table 1-5 on page 1-19.)
The compiler does not support the _Complex and _Imaginary keywords. Complex arithmetic in C mode is enabled by including the
Analog Devices-specific header file <complex.h>.
.c is compiled and linked in C++ mode.
C++ is not supported on the ADSP-21020 processor.
1-20VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
C/C++ Compiler Common Switch Descriptions
The following command-line switches apply in both C and C++ modes.
sourcefile
The sourcefile parameter (or parameters) specifies the name of the file
(or files) to be preprocessed, compiled, assembled, and/or linked. A file
name can include the drive, directory, file name, and file extension. The
cc21k compiler uses the file extension to determine the operations to
perform.
-@ filename
The -@filename (command file) switch directs the compiler to read
command-line input from filename. The specified file must contain
driver options but may also contain source filenames and environment
variables. It can be used to store frequently used options as well as to read
from a file list.
-A name[tokens]
The -A (assert) switch directs the compiler to assert name as a predicate
with the specified tokens. This has the same effect as the #assert preprocessor directive. The following assertions are predefined in Table 1-6.
Table 1-6. Predefined Assertions
AssertionValue
system
machineadsp21xxx
cpuadsp21xxx
compilercc21k
embedded
VisualDSP++ 5.0 C/C++ Compiler Manual 1-21
for SHARC Processors
Compiler Command-Line Interface
The
-A name(value) switch is equivalent to including
#assert name(value)
in your source file, and both may be tested in a preprocessor condition in
the following manner:
#if #name(value)
// do something
#else
// do something else
#endif
For example, the default assertions may be tested as:
#if #machine(adsp21xxx)
// do something
#endif
-add-debug-libpaths
switch, to prevent misinterpretation. No quotes are needed for a
#assert directive in a source file.
The -add-debug-libpaths switch prepends the Debug subdirectory to the
search paths passed to the linker. The Debug subdirectory, found in each
of the silicon-revision-specific library directories, contains variants of certain libraries (for example, system services), which provide additional
diagnostic output to assist in debugging problems arising from their use.
Invoke this switch with the Use Debug System Libraries radio but-
The parentheses in the assertion need quotes when using the -A
ton located in the VisualDSP++ Project Options dialog box, Link
page, Processor category.
1-22VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
-aligned-stack
The -aligned-stack switch directs the compiler to align the program
stack on a double-word boundary.
-alttok
The -alttok (alternative tokens) switch directs the compiler to allow
alternative operator keywords and digraph sequences in source files.
Additionally, this switch enables the recognition of these alternative operator keywords in C++ source files (Table 1-7).
Table 1-7. Alternative Operator Keywords
KeywordEquivalent
and &&
and_eq &=
bitand&
bitor|
compl~
or||
or_eq|=
not!
not_eq!=
xor^
xor_eq^=
See also the
-no-alttok switch (on page 1-41).
To use alternative tokens in C, you should use #include
<iso646.h>
.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-23
for SHARC Processors
Compiler Command-Line Interface
-always-inline
The -always-inline switch instructs the compiler to always attempt to
inline any call to a function that is defined with the inline qualifier. It is
equivalent to applying #pragma always_inline to all functions in the
module that have the inline qualifier. See also the –never-inline switch
(on page 1-41).
-annotate
The -annotate (enable assembly annotations) switch directs the compiler
to annotate assembly files generated by the compiler. The default behavior
is that whenever optimizations are enabled all assembly files generated by
the compiler are annotated with information on the performance of the
generated assembly. See “Assembly Optimizer Annotations” on page 2-80
for more details on this feature. Also, see also the –no-annotate switch
(on page 1-41).
-annotate-loop-instr
The -annotate-loop-instr switch directs the compiler to provide additional annotation information for the prolog, kernel and epilog of a loop.
See “Assembly Optimizer Annotations” on page 2-80 for more details on
this feature. Also, see also the
(on page 1-42).
Invoke this switch with the Always radio button located in the
Inlining area of the VisualDSP++ Project Options dialog box,
Compile page, General category.
Invoke this switch by checking the Generate assembly code anno-tations check box located in the VisualDSP++ Project Options
dialog box, Compile page, General category.
–no-annotate-loop-instr switch
1-24VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
-auto-attrs
The -auto-attrs (automatic attributes) switch directs the compiler to
emit automatic attributes based on the files it compiles. Emission of automatic attributes is enabled by default. See “File Attributes” on page 1-387
for more information about attributes, and what automatic attributes the
compiler emits. See also the -no-auto-attrs switch (on page 1-42) and
the -file-attr switch (on page 1-31).
-build-lib
The -build-lib (build library) switch directs the compiler to use elfar
(the librarian) to produce a library file (.dlb) as the output instead of
using the linker to produce an executable file (.dxe). The -o option must
be used to specify the name of the resulting library.
-C
The -C (comments) switch, which may only be run in combination with
the -E or -P switches, directs the C/C++ preprocessor to retain comments
in its output file.
-c
The -c (compile only) switch directs the compiler to compile and/or
assemble the source files, but stop before linking. The output is an object
file (.doj) for each source file.
-compatible-pm-dm
The compatible-pm-dm switch specifies that the compiler shall treat dmand
pm-qualified pointers as assignment-compatible.
-const-read-write
The -const-read-write switch directs the compiler to specify that constants may be accessed as read-write data (as in ANSI C). The compiler’s
VisualDSP++ 5.0 C/C++ Compiler Manual 1-25
for SHARC Processors
Compiler Command-Line Interface
default behavior assumes that data referenced through
never changes.
The -const-read-write switch changes the compiler’s behavior to match
the ANSI C assumption, which is that other non-const pointers may be
used to change the data at some point.
-const-strings
The -const-strings (const-qualify strings) switch directs the compiler to
mark string literals as const-qualified. This is the default behavior. See
also the -no-const-strings switch (on page 1-43).
-D
Invoke this switch with the Pointers to const may point to
non-const data check box located in the Constants area of the VisualDSP++ Project Options dialog box, Compile page, Lan-
guage Settings category.
Invoke this switch with the Literal strings are const check box
located in the Constants area of the VisualDSP++ Project Options
dialog box, Compile page, Language Settings category.
const pointers
The -Dmacro[=definition] (define macro) switch directs the compiler to
define a macro. If you do not include the optional definition string, the
compiler defines the macro as the string ‘1’. Note that the compiler processes all -D switches on the command line before any -U (undefine macro)
switches. For more information, see “-U” on page 1-64.
-debug-types
The -debug-types switch builds a *.h file directly and writes a complete
set of debugging information for the header file. The
be specified with the -debug-types switch because it is implied. For
example,
cc21k -debug-types anyHeader.h
1-26VisualDSP++ 5.0 C/C++ Compiler Manual
-g option need not
for SHARC Processors
Compiler
Until the introduction of
*.h file as a valid input file. The implicit -g option writes debugging infor-
-debug-types, the compiler would not accept an
mation for only those typedefs that are referenced in the program. The
-debug-types option provides complete debugging information for all
typedefs and structs.
-double-size[-32|-64]
The -double-size-32 (double is 32 bits) and the -double-size-64 (double is 64 bits) switches select the storage format that the compiler uses for
type double. The default mode is -double-size-32.
The C/C++ type double poses a special problem for the compiler. The C
and C++ languages default to double for floating-point constants and
many floating-point calculations. If double has the customary size of 64
bits, many programs inadvertently use slow speed emulated 64-bit
floating-point arithmetic, even when variables are declared consistently as
float.
To avoid this problem, cc21k provides a mode in which double is the
same size as float. This mode is enabled with the -double-size-32 switch
and is the default mode.
Representing double using 32 bits gives good performance and provides
enough precision for most DSP applications. This, however, does not fully
conform to the C and C++ standards. The standard requires that
double
maintains 10 digits of precision, which requires 64 bits of storage. The
-double-size-64 switch sets the size of double to 64 bits for full standard
conformance.
With -double-size-32, a double is stored in 32-bit IEEE single-precision
format and is operated on using fast hardware floating-point instructions.
Standard math functions such as sin also operate on 32-bit values. This
mode is the default and is recommended for most programs. Calculations
that need higher precision can be done with the
long double type, which
is always 64 bits.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-27
for SHARC Processors
Compiler Command-Line Interface
With
-double-size-64, a double is stored in 64-bit IEEE double-preci-
sion format and is operated on using slow floating-point emulation
software. Standard math functions such as sin also operate on 64-bit values and are similarly slow. This mode is recommended only for porting
code that requires that double have more than 32 bits of precision.
The -double-size-32 switch defines the __DOUBLES_ARE_FLOATS__ macro,
while the -double-size-64 switch undefines the __DOUBLES_ARE_FLOATS__
macro.
-double-size-any
The -double-size-any switch specifies that the input source files make no
use of double-typed data, and that the resulting object files should be
marked in such a way that will enable them to be linked against objects
built with doubles either 32-bit or 64-bit in size.
-dry
The -dry (verbose dry run) switch directs the compiler to display main
cc21k actions, but not to perform them.
-dryrun
The -dryrun (terse dry run) switch directs the compiler to display
top-level
Invoke this switch with the Double size radio buttons located in
the VisualDSP++ Project Options dialog box, Compile tab, Compile category, Processor (1) subcategory.
Invoke this switch with the Allow mixing of sizes check box
located in the VisualDSP++ Project Options dialog box, Compile
page, Processor (1) category.
cc21k actions, but not to perform them.
1-28VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
-E
The -E (stop after preprocessing) switch directs the compiler to stop after
the C/C++ preprocessor runs (without compiling). The output
(preprocessed source code) prints to the standard output stream unless the
output file is specified with the -o switch.
-ED
The -ED (run after preprocessing to file) switch directs the compiler to
write the output of the C/C++ preprocessor to a file named
original_filename.i. After preprocessing, compilation proceeds
normally.
located in the VisualDSP++ Project Options dialog box, Compile
page, General category.
Invoke this switch with the Generate preprocessed file check box
-EE
The -EE (run after preprocessing) switch is similar to the -E switch, but it
does not halt compilation after preprocessing.
-eh
The -eh (enable exception handling) switch directs the compiler to allow
C++ code that contains catch statements and throw expressions and other
features associated with ANSI/ISO standard C++ exceptions. When this
switch is enabled, the compiler defines the macro
__EXCEPTIONS to be 1.
If used when compiling C programs, without the -c++ (C++ Mode) switch
(on page 1-20), the -eh switch directs the compiler to generate exceptions
tables but does not change the language accepted. In this case
__EXCEPTIONS is not defined.
The –eh switch also causes the compiler to define __ADI_LIBEH__ during
the linking stage so that appropriate sections can be activated in the .
ldf
VisualDSP++ 5.0 C/C++ Compiler Manual 1-29
for SHARC Processors
Compiler Command-Line Interface
file, and the program can be linked with a library built with exceptions
enabled.
Object files created with exceptions enabled may be linked with objects
created without exceptions. However, exceptions can only be thrown from
and caught, and cleanup code executed, in modules compiled with
an attempt is made to throw an exception through the execution of a function not compiled -eh then abort or the function registered with
set_terminate is called. See also “#pragma generate_exceptions_tables”
on page 1-254 and the -no-eh switch (on page 1-43).
In non-threaded applications, the buffer used for the passing of exception
data is not returned to the heap on application exit. This is to avoid
unnecessary code and will have no impact on behavior.
-eh. If
-enum-is-int
The -enum-is-int switch ensures that the type of an enum is int. By
default, the compiler defines enumeration types with integral types larger
than int, if int is insufficient to represent all the values in the enumeration. This switch prevents the compiler from selecting a type wider than
int.
-extra-keywords
The -extra-keywords (enable short-form keywords) switch directs the
compiler to recognize the Analog Devices keyword extensions to
ANSI/ISO standard C and C++, such as
scores, which can affect conforming ANSI/ISO C and C++ programs.
This is the default mode.
Invoke this switch with the C++ exceptions and RTTI check box
located in the VisualDSP++ Project Options dialog box, Compile
page, Language Settings category.
pm and dm, without leading under-
1-30VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
The
-no-extra-keywords switch (on page 1-44) can be used to disallow
support for the additional keywords. Table 1-17 on page 1-131 provides a
list and a brief description of keyword extensions.
-file-attr name[=value]
The -file-attr (file attribute) switch directs the compiler to add the
specified attribute name/value pair to all the files it compiles. To add multiple attributes, use the switch multiple times. If "=value" is omitted, the
default value of “1” will be used. See the section “File Attributes” on
page 1-387 for more information about attributes, and what automatic
attributes the compiler emits. See also the -auto-attrs switch
(on page 1-25) and the -no-auto-attrs switch (on page 1-42).
in the VisualDSP++ Project Options dialog box, Compile page,
General category.
Invoke this switch with the Additional attributes text field located
-flags
The -flags-{asm|compiler|lib|link|mem} switch [,switch2 [,...]]
(command-line input) switch directs the compiler to pass command-line
switches to the other build tools.
The tools are listed in Table 1-8.
Table 1-8. Switches Passed to Other Build Tools
OptionTool
-flags-asmAssembler
-flags-compilerCompiler executable
-flags-libLibrary Builder (elfar.exe)
-flags-link
-flags-memMemory Initializer
Linker
VisualDSP++ 5.0 C/C++ Compiler Manual 1-31
for SHARC Processors
Compiler Command-Line Interface
-float-to-int
The -float-to-int switch instructs the compiler to use a support library
function to convert a float to an integer. The library support routine performs extra checking to avoid a floating-point underflow occurring.
-force-circbuf
The -force-circbuf (circular buffer) switch instructs the compiler to
make use of circular buffer facilities, even if the compiler cannot verify
that the circular index or pointer is always within the range of the buffer.
Without this switch, the compiler’s default behavior is conservative, and
does not use circular buffers unless it can verify that the circular index or
pointer is always within the circular buffer range. See “Circular Buffer
Built-In Functions” on page 1-180.
-fp-associative
The -fp-associative switch directs the compiler to treat floating-point
multiplication and addition as an associative. This switch is on by default.
See the -no-fp-associative switch (on page 1-44) for more information.
-full-version
The -full-version (display versions) switch directs the compiler to display version information for build tools used in a compilation.
Invoke this switch with the Even when pointer may be outside
buffer range check box located in the VisualDSP++ Project
Options dialog box, Compile page, Language Settings category.
1-32VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
-fx-contract
The -fx-contract switch sets the default state of FX_CONTRACT to ON,
which is the default setting. This switch controls the performance and
accuracy of arithmetic on the native fixed-point type, fract. See
“FX_CONTRACT” on page 1-99 for more information.
See also “-no-fx-contract” on page 1-44.
-fx-rounding-mode-biased
The -fx-rounding-mode-biased switch sets the default state of
FX_ROUNDING_MODE to BIASED. This switch controls the rounding behavior
of arithmetic on the native fixed-point type, fract. See “Setting the
Rounding Mode” on page 1-111 for more information.
-fx-rounding-mode-truncation
The -fx-rounding-mode-truncation switch sets the default state of
FX_ROUNDING_MODE to TRUNCATION, which is the default setting. This switch
controls the rounding behavior of arithmetic on the native fixed-point
type, fract. See “Setting the Rounding Mode” on page 1-111 for more
information.
-fx-rounding-mode-unbiased
The -fx-rounding-mode-unbiased switch sets the default state of
FX_ROUNDING_MODE to UNBIASED. This switch controls the rounding behav-
ior of arithmetic on the native fixed-point type,
fract. See “Setting the
Rounding Mode” on page 1-111 for more information.
-g
The -g (generate debug information) switch directs the compiler to output symbols and other information used by the debugger.
When the
-O) switch, the compiler performs standard optimizations. The compiler
(
-g switch is used in conjunction with the enable optimization
VisualDSP++ 5.0 C/C++ Compiler Manual 1-33
for SHARC Processors
Compiler Command-Line Interface
also outputs symbols and other information to provide limited
source-level debugging through the VisualDSP++ IDDE (debugger). This
combination of options provides line debugging and global variable
debugging.
-glite
The -glite (lightweight debugging) switch can be used on its own, or in
conjunction with any of the -g, -Og or -debug-types compiler switches.
When this switch is enabled it instructs the compiler to remove any
unnecessary debug information for the code that is compiled.
When used on its own, the switch also enables the -g option.
When the -g and -O switches are specified, no debug information is
available for local variables and the standard optimizations can
sometimes rearrange program code in a way that inaccurate line
number information may be produced. For full debugging capabilities, use the -g switch without the -O switch. See also the -Og
switch (on page 1-49).
Invoke this switch by selecting the Generate debug information
check box in the VisualDSP++ Project Options dialog box, Compile tab, General category.
This switch can be used to reduce the size of object and executable
files, but will have no effect on the size of the code loaded onto the
target.
-H
The -H (list headers) switch directs the compiler to output only a list of
the files included by the preprocessor via the
compiling.
1-34VisualDSP++ 5.0 C/C++ Compiler Manual
#include directive, without
for SHARC Processors
Compiler
-HH
The -HH (list headers and compile) switch directs the compiler to output
to the standard output stream a list of the files included by the preprocessor via the #include directive. After preprocessing, compilation proceeds
normally.
-h[elp]
The -help (command-line help) switch directs the compiler to output a
list of command-line switches with a brief syntax description.
-I
The -Idirectory [{,|;} directory...] (include search directory)
switch directs the C/C++ compiler preprocessor to append the directory
(directories) to the search path for include files. This option can be specified more than once; all specified directories are added to the search path.
Include files, whose names are not absolute path names and that are
enclosed in “...” when included, are searched for in the following directories in this order:
VisualDSP++ 5.0 C/C++ Compiler Manual 1-35
for SHARC Processors
Invoke this switch with the Additional include directories text
field located in the VisualDSP++ Project Options dialog box,
Compile page, Preprocessor category.
1. The directory containing the current input file (the primary source
file or the file containing the #include)
2. Any directories specified with the -I switch in the order they are
listed on the command line
3. Any directories on the standard list:
<VDSP++ install dir>/.../include
If a file is included using the <...> form, this file is only searched
for by using directories defined in items 2 and 3 above.
Compiler Command-Line Interface
-I-
The -I- (start include directory list) switch establishes the point in the
include directory list at which the search for header files enclosed in angle
brackets begins. Normally, for header files enclosed in double quotes, the
compiler searches in the directory containing the current input file; then
the compiler reverts back to looking in the directories specified with the
-I switch and then in the standard include directory.
It is possible to replace the initial search (within the directory containing
the current input file) by placing the -I- switch at the point on the command line where the search for all types of header file begins. All include
directories on the command line specified before the -I- switch are used
only in the search for header files that are enclosed in double quotes.
-i
The -i (less includes) switch can be used with the –H, -HH, -M, or -MM
switches to direct the compiler to only output header details (-H, -HH) or
makefile dependencies (-M, -MM) for include files specified in double
quotes.
-implicit-pointers
The -implicit-pointers (implicit pointer conversion) switch allows a
pointer to one type to be converted to a pointer to another without the use
of an explicit cast. The compiler produces a discretionary warning rather
than an error in such circumstances. This option is not valid when compiling in C++ mode.
The -I switch removes the directory containing the current input
file from the include directory list.
1-36VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
For example, the following code will not compile without this switch:
int *foo(int *a) {
return a;
}
int main(void) {
char *p = 0, *r;
r = foo(p);/* Bad: normally produces an error */
return 0;
}
In this example, both the argument to foo and the assignment to r will be
faulted by the compiler. Using -implicit-pointers converts these errors
into warnings.
ble pointer types check box located in the VisualDSP++ Project
Options dialog box, Compile page, Language Settings category.
Invoke the -implicit-pointers switch with the Allow incompati-
-include
The -includefilename (include file) switch directs the preprocessor to
process the specified file before processing the regular input file. Any -D
and -U options on the command line are always processed before an
-include file. Only one -include may be given.
-ipa
The -ipa (interprocedural analysis) switch turns on Interprocedural
Analysis (IPA) in the compiler. This option enables optimization across
the entire program, including between source files that were compiled separately. If used, the
-ipa option should be applied to all C and C++ files in
the program.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-37
for SHARC Processors
Compiler Command-Line Interface
For more information, see “Interprocedural Analysis” on page 1-84. Spec-
ifying
-ipa also implies setting the -O switch (on page 1-48).
-L
The -Ldirectory[{;|,}directory…] (library search directory) switch
directs the compiler to append the directory to the search path for library
files.
-l
The -llibrary (link library) switch directs the compiler to search the
library for functions and global variables when linking. The library name
is the portion of the file name between the lib prefix and the .dlb
extension.
For example, the -lc compiler switch directs the linker to search in the
library named c. This library resides in a file named libc.dlb.
When using this switch, list all object files on the command line before
listing libraries using the -l switch. When a reference to a symbol is made,
the symbol definition will be taken from the left-most object or library on
the command line that contains the global definition of that symbol. If
two objects on the command line contain definitions of the symbol x, x
will be taken from the left-most object on the command line that contains
a global definition of
Invoke this switch by selecting the Interprocedural Analysis check
box in the VisualDSP++ Project Options dialog box, Compile tab, General category.
x.
1-38VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
If one of the definitions for
x comes from user objects, and the other from
a user library, and the library definition should be overridden by the user
object definition, it is important that the user object comes before the
library on the command line.
Libraries included in the default .ldf file are searched last for symbol
definitions.
-list-workarounds
The -list-workarounds (list supported errata workarounds) switch displays a list of all errata workarounds which the compiler supports. See
“Controlling Silicon Revision and Anomaly Workarounds Within the
Compiler” on page 1-86 for details of valid workarounds and the interac-
tion of the -si-revision, -workaround and -no-workaround switches.
-M
The -M (generate make rules only) switch directs the compiler not to compile the source file, but to output a rule suitable for the make utility,
describing the dependencies of the main program file. The format of the
make rule output by the preprocessor is:
object-file: include-file …
-MD
The -MD (generate make rules and compile) switch directs the preprocessor
to print to a file called
original_filename.d a rule describing the depen-
dencies of the main program file. After preprocessing, compilation
proceeds normally. See also the –Mo switch.
-MM
The -MM (generate make rules and compile) switch directs the preprocessor
to print to standard out a rule describing the dependencies of the main
program file. After preprocessing, compilation proceeds normally.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-39
for SHARC Processors
Compiler Command-Line Interface
-Mo
The -Mofilename (preprocessor output file) switch directs the compiler
to use filename for the output of –MD or –ED switches.
-Mt
The -Mtname (output make rule for the named source) switch modifies the
target of generated dependencies, renaming the target to name. It only has
an effect when used in conjunction with the -M or -MM switch.
-map
The -mapfilename (generate a memory map) switch directs the compiler
to output a memory map of all symbols. The map file name corresponds
to the filename argument. For example, if the argument is test, the map
file name is test.xml. The .xml extension is added where necessary.
-mem
The -mem (enable memory initialization) switch directs the compiler to
run the mem21k initializer (utility). The memory initializer can be controlled through the -flags-mem switch (on page 1-31). See the -no-mem
switch (on page 1-45) for more information.
-multiline
The -multiline switch enables a compiler GNU compatibility mode
which allows string literals to span multiple lines without the need for a
“\” at the end of each line. This is the default mode. See the
line switch (on page 1-45) for more information.
1-40VisualDSP++ 5.0 C/C++ Compiler Manual
Invoke this switch with the Allow multi-line character strings
check box located in the VisualDSP++ Project Options dialog box,
Compile page, Language Settings category.
for SHARC Processors
-no-multi-
Compiler
-never-inline
The -never-inline switch instructs the compiler to ignore the inline
qualifier on function definitions, so that no calls to such functions will be
inlined. See also “-always-inline” on page 1-24.
-no-aligned-stack
The -no-aligned-stack (disable stack alignment) switch directs the compiler to not align the program stack on a double-word boundary. For more
information, see “-aligned-stack” on page 1-23.
-no-alttok
The -no-alttok (disable alternative tokens) switch directs the compiler
not to accept alternative operator keywords and digraph sequences in the
source files. This is the default mode. For more information, see “-alttok”
on page 1-23.
-no-annotate
The -no-annotate (disable assembly annotations) switch directs the compiler not to annotate assembly files generated by the compiler. The default
behavior is that whenever optimizations are enabled all assembly files generated by the compiler are annotated with information on the
performance of the generated assembly. See “Assembly Optimizer Annota-
tions” on page 2-80 for more details on this feature. For more
information, see “-annotate” on page 1-24.
Invoke this switch with the Never check box located in the Inlining
area of the VisualDSP++ Project Options dialog box, Compile
page, General category.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-41
for SHARC Processors
Invoke this switch by clearing the Generate assembly code annota-tions check box located in the VisualDSP++ Project Options
dialog box, Compile page, General category.
Compiler Command-Line Interface
-no-annotate-loop-instr
The -no-annotate-loop-instr switch disables the production of additional loop annotation information by the compiler. This is the default
mode. See the -annotate--loop-instr switch (on page 1-24).
-no-auto-attrs
The -no-auto-attrs (no automatic attributes) switch directs the compiler
not to emit automatic attributes based on the files it compiles. Emission of
automatic attributes is enabled by default. See “File Attributes” on
page 1-387 for more information about attributes, and what automatic
attributes the compiler emits. See also the -auto-attrs switch
(on page 1-25) and the -file-attr switch (on page 1-31). For more
information, see “-auto-attrs” on page 1-25.
-no-builtin
The -no-builtin (no built-in functions) switch directs the compiler not
to generate short names for the built-in functions (for example, abs()),
and to accept only the full name (for example, __builtin_abs()). Note
that this switch influences many functions. This switch also predefines the
__NO_BUILTIN preprocessor macro. For more information on built-in func-
tions, see “Compiler Built-In Functions” on page 1-177.
Invoke this switch by clearing the Auto-generated attributes check
box located in the VisualDSP++ Project Options dialog box,
Compile page, General category.
Invoke this switch by selecting the Disable builtin functions check
box in the VisualDSP++ Project Options dialog box, Compile tab, Language Settings category.
1-42VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
-no-circbuf
The -no-circbuf (no circular buffer) switch disables the automatic generation of circular buffer code by the compiler. Uses of the circindex() and
circptr() functions (that is, explicit circular buffer operations) are not
affected.
-no-const-strings
The -no-const-strings switch directs the compiler not to make string literals const qualified. See the -const-strings switch (on page 1-26) for
more information.
-no-db
The -no-db (no delayed branches) switch specifies that the compiler shall
not generate jumps that use delayed branches.
-no-defs
The -no-defs (disable defaults) switch directs the preprocessor not to
define any default preprocessor macros, include directories, library directories, libraries, and run-time headers. It also disables the Analog Devices
cc21k C/C++ keyword extensions.
Invoke this switch with the Never check box located in the
Circular Buffer Generation area of the VisualDSP++ Project Options dialog box, Compile page, Language Settings category.
Disabling of interrupts within the epilogue code of a re-entrant
interrupt function still uses a delayed branch jump to minimise
interrupt latency.
-no-eh
The -no-eh (disable exception handling) switch directs the compiler to
disallow ANSI/ISO C++ exception handling. This is the default mode. See
the -eh switch (on page 1-29) for more information.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-43
for SHARC Processors
Compiler Command-Line Interface
-no-extra-keywords
The -no-extra-keywords (disable short-form keywords) switch directs the
compiler not to recognize the Analog Devices keyword extensions that
might affect conformance to ISO/ANSI standards for C and C++ languages. These include keywords such as pm and dm, which may be used as
identifiers in standard conforming programs. Alternate keywords, which
are prefixed with two leading underscores, such as __pm and __dm,
continue to work. See the -extra-keywords switch (on page 1-30) for
more information.
-no-fp-associative
The -no-fp-associative switch directs the compiler NOT to treat
floating-point multiplication and addition as an associative. See the
-fp-associative switch (on page 1-32) for more information.
-no-fx-contract
The -no-fx-contract switch sets the default state of FX_CONTRACT to OFF.
This switch controls the performance and accuracy of arithmetic on the
native fixed-point type,
more information.
See also “-fx-contract” on page 1-33.
Invoke this switch with the Disable Analog Devices extension key-words check box located in the VisualDSP++ Project Options
dialog box, Compile page, Language Settings category.
Invoke this switch with the Do not treat floating point operations
as associative check box located in the VisualDSP++ Project
Options dialog box, Compile page, Language Settings category.
fract. See “FX_CONTRACT” on page 1-99 for
1-44VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
-no-mem
The -no-mem (disable memory initialization) switch directs the compiler
not to run the mem21k initializer. Note that if you use -no-mem, the compiler does not initialize globals and statics. See the -mem switch
(on page 1-40) for more information.
-no-multiline
The -no-multiline switch disables a compiler GNU compatibility mode
which allows string literals to span multiple lines without the need for a
“\” at the end of each line. See the -multiline switch (on page 1-40) for
more information.
strings check box located in the VisualDSP++ Project Options dialog box, Compile page, Language Settings category.
Invoke this switch by clearing the Allow multi-line character
-no-progress-rep-timeout
The -no-progress-rep-timeout (disable progress message for long compilations) switch disables the diagnostic message issued by the compiler to
indicate that it is still working, when a function’s compilation is taking an
excessively long time. The message is disabled by default. See also the
-progress-rep-timeout switch (on page 1-57) and the
-progress-rep-timeout-secs switch (on page 1-57).
-no-sat-associative
The -no-sat-associative (saturating addition is not associative) switch
instructs the compiler not to consider saturating addition operations as
associative:
(a+b)+c may not be rewritten as a+(b+c), when the addition
operator saturates. The default is that saturating addition is not associative. See the
-sat-associative switch (on page 1-59) for more
information.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-45
for SHARC Processors
Compiler Command-Line Interface
-no-saturation
The -no-saturation switch directs the compiler not to introduce faster
operations in cases where the faster operation would saturate (if the
expression overflowed) when the original operation would have wrapped
the result. The code produced may be less efficient than when the switch
is not used. Saturation is enabled by default when optimizing, and may be
disabled by this switch. Saturation is disabled when not optimizing (this
switch is the default when not optimizing).
-no-shift-to-add
The -no-shift-to-add switch prevents the compiler from replacing a
shift-by-one instruction with an addition. While this can produce faster
code, it can also lead to arithmetic overflow.
-no-simd
The -no-simd (disable SIMD mode) switch directs the compiler to disable
automatic SIMD code generation when compiling for ADSP-211xx,
ADSP-212xx, ADSP-213xx, or ADSP-214xx processors. Note that SIMD
code is still generated for a loop if it is preceded with the "
pragma. The pragma is treated as an explicit user request to generate
SIMD code and is always obeyed, if possible. See “SIMD Support” on
page 1-271 for more information.
Invoke this switch from the Disable shift-to-add conversion check
box located in the VisualDSP++ Project Options dialog box,
Compile page, Processor (1) category.
SIMD_for"
Invoke this switch from the Disable automatic SIMD code generation check box located in the VisualDSP++ Project Options
dialog box, Compile page, Processor (1) category.
1-46VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
-no-std-ass
The -no-std-ass (disable standard assertions) switch prevents the compiler from defining the standard assertions. See the -A switch
(on page 1-21) for the list of standard assertions.
-no-std-def
The -no-std-def (disable standard macro definitions) switch prevents the
compiler from defining default preprocessor macro definitions.
-no-std-inc
The -no-std-inc (disable standard include search) switch directs the
C/C++ preprocessor to search for header files in the current directory and
directories specified with the -I switch.
-no-std-lib
The -no-std-lib (disable standard library search) switch directs the compiler to search for libraries in only the current project directory and
directories specified with the
-no-threads
The -no-threads (disable thread-safe build) switch directs the compiler to
link against the non-thread-safe variants of the C/C++ run-time library.
This is the default.
This switch also disables the Analog Devices keyword extensions
that have no leading underscores, such as pm and dm.
You can invoke this switch by selecting the Ignore standard include paths check box in the VisualDSP++ Project Options dialog box, Compile tab, Preprocessor category.
-L switch.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-47
for SHARC Processors
Compiler Command-Line Interface
-no-workaround
The -no-workaroundworkaround_id (disable avoidance of specific errata)
switch disables compiler code generator workarounds for specific hardware errata. See “Controlling Silicon Revision and Anomaly Workarounds
Within the Compiler” on page 1-86 for details of valid workarounds and
the interactions of the -si-revision, -workaround and -no-workaround
switches.
-normal-word-code
The -normal-word-code switch has the same effect as compiling with the
-nwc switch. It directs the compiler to generate instructions of normal
word size (48-bits). This switch applies only when compiling code targeted for ADSP-214xx processors.
-nwc
The -nwc switch has the same effect as compiling with the
-normal-word-code switch. It directs the compiler to generate instructions
of normal word size (48-bits). This switch applies only when compiling
code targeted for ADSP-214xx processors.
-O[0|1]
The -O (enable optimizations) switch directs the compiler to produce code
that is optimized for performance. Optimizations are not enabled by
default for the
the uppercase letter “O” and end with a digit—a zero or a one.) The
switch setting -O or -O1 turns optimization on, while setting -O0 turns off
all optimizations.
1-48VisualDSP++ 5.0 C/C++ Compiler Manual
You can invoke this switch by selecting the Enable optimization
check box in the VisualDSP++ Project Options dialog box, Compile tab, General category.
cc21k compiler. (Note that the switch settings begin with
for SHARC Processors
Compiler
-Oa
The -Oa (automatic function inlining) switch enables the inline expansion
of C/C++ functions, which are not necessarily declared inline in the source
code. The amount of auto-inlining the compiler performs is controlled
using the –Ov (optimize for speed versus size) switch (on page 1-49).
Therefore, use of -Ov100 indicates that as many functions as possible are
auto-inlined, whereas –Ov0 prevents any function from being auto-inlined.
Specifying -Oa also implies the use of -O.
-Og
The -Og switch enables a compiler mode that attempts to perform optimizations while still preserving the debugging information. It is meant as an
alternative for those who want a debuggable program but who are also
concerned about the performance of their debuggable code and are less
concerned about the compilation time.
-Os
The -Os (optimize for size) switch directs the compiler to produce code
that is optimized for size. This is achieved by performing all optimizations
except those that increase code size. The optimizations not performed
include loop unrolling, some delay slot filling, and jump avoidance.
-Ov
The -Ovnum (optimize for speed versus size) switch informs the compiler
of the relative importance of speed versus size, when considering whether
such trade-offs are worthwhile. The
between 0 (purely size) and 100 (purely speed).
Invoke this switch with the Automatic check box located in the
Inlining area of the VisualDSP++ Project Options dialog box, Compile page, General category.
num variable should be an integer
VisualDSP++ 5.0 C/C++ Compiler Manual 1-49
for SHARC Processors
Compiler Command-Line Interface
0
Execution
count
Optimize for speed
-Ovnum
0100
Infinity
Optimize
for space
Limit line
For any given optimization, the compiler modifies the code being generated. Some optimizations produce code that will execute in fewer cycles,
but which will require more code space. In such cases, there is a trade-off
between speed and space.
The
num variable indicates a sliding scale between 0 and 100 which is the
probability that a linear piece of generated code—a “basic block”—will be
optimized for speed or for space. At -Ov0 all blocks are optimized for space
and at -Ov100 all blocks are optimized for speed. At any point in between,
the decision is based upon num and how many times the block is expected
to be executed—the “execution count” of the block. Figure 1-1 demonstrates this relationship.
1-50VisualDSP++ 5.0 C/C++ Compiler Manual
Figure 1-1. -Ov Switch Optimization Curve
for SHARC Processors
Compiler
For any given optimization where speed and size conflict, the potential
benefit is dependent on the execution count: an optimization that
increases performance at the expense of code size is considerably more
beneficial if applied to the core loop of a critical algorithm than if applied
to one-time initialization code or to rarely-used error-handling functions.
If code appears to be executed only once, it will be optimized for space. As
its execution count increases, so too does the likelihood that the compiler
will consider the code increase worthwhile for the corresponding benefit
in performance.
As Figure 1-1 shows, the
cution count is considered sufficient to switch optimization from “for
space” to “for speed”. Where num is a low value, the compiler is biased
towards space, so a block’s execution count has to be relatively high for the
compiler to apply code-increasing transformations. Where num has a high
value, the compiler is biased towards speed, so the same transformation
will be considered valid for a much lower execution count.
The -Ov switch is most effective when used in conjuction with profileguided optimization, where accurate execution counts are available. Without profile-guided optimization, the compiler makes estimates of the
relative execution counts using heuristics.
For more information, see “Using Profile-Guided Optimization” in
Chapter 2, Achieving Optimal Performance From C/C++ Source Code.
-o
The -ofilename (output file) switch directs the compiler to use filename
for the name of the final output file.
Invoke this switch with the Optimize for code size/speed slider
located in the VisualDSP++ Project Options dialog box, Compile
page, General category.
-Ov switch affects the point at which a given exe-
VisualDSP++ 5.0 C/C++ Compiler Manual 1-51
for SHARC Processors
Compiler Command-Line Interface
-overlay
The -overlay (program may use overlays) switch will disable the propagation of register information between functions and force the compiler to
assume that all functions clobber all scratch registers. Note that this switch
will affect all functions in the source file, and may result in a performance
degradation. For information on disabling the propagation of register
information only for specific functions, see “#pragma overlay” on
page 1-217.
-overlay-clobbers
The -overlay-clobbersclobbered-regs (registers clobbered by overlay
manager) switch identifies the set of registers clobbered by an overlay
manager, if one is used. The compiler will assume that any call to an
overlay-managed function will clobber the values in clobbered-regs, in
addition to those clobbered by the function in question. A function is
considered to be an overlay-managed function if the -overlay switch
(on page 1-52) is specified, or if the function is marked with #pragma
overlay
(on page 1-217).
The clobbered-regs variable is a single string formatted as per the argument to #pragma regs_clobbered, except that individual components of
the list may also be separated by commas.
Whitespace and semi-colons are valid separators for the components of the list, but must be properly quoted when being passed to
the compiler.
for SHARC Processors
Compiler
-P
The -P (omit line numbers) switch directs the compiler to stop after the
C/C++ preprocessor runs (without compiling) and to omit the #line preprocessor command with line number information from the preprocessor
output. The -C switch can be used in conjunction with -P to retain
comments.
-PP
The -PP (omit line numbers and compile) switch is similar to the -P
switch; however, it does not halt compilation after preprocessing.
-path-{ asm | compiler | lib | link }
The -path-{asm|compiler|lib|link}pathname (tool location) switch
directs the compiler to use the specified component in place of the
default-installed version of the compilation tool. The component
comprises a relative or absolute path to its location. Respectively, the tools
are the assembler, compiler, librarian, or linker. Use this switch when
overriding the normal version of one or more of the tools. The
-path-{...} switch also overrides the directory specified by the
-path-install switch.
-path-install
The -path-install directory (installation location) switch directs the
compiler to use the specified directory as the location for all compilation
tools instead of the default path. This is useful when working with multiple versions of the tool set.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-53
for SHARC Processors
You can selectively override this switch with the -path-{asm|com-
piler|lib|link}
switch.
Compiler Command-Line Interface
-path-output
The -path-output directory (non-temporary files location) switch directs
the compiler to place final output files in the specified directory.
-path-temp
The -path-tempdirectory (temporary files location) switch directs the
compiler to place temporary files in the specified directory.
-pch
The -pch (precompiled header) switch directs the compiler to automatically generate and use precompiled header files. A precompiled output
header has a .pch extension attached to the source file name. By default,
all precompiled headers are stored in a directory called PCHRepository.
-pchdir
The -pchdirdirectory (locate PCHRepository) switch specifies the location of an alternative PCHRepository for storing and invocation of
precompiled header files. If the directory does not exist, the compiler creates it. Note that -o (output) does not influence the -pchdir option.
-pgo-session
The -pgo-sessionsession-id (specify PGO session identifier) switch is
used with profile-guided optimization. It has the following effects:
•When used with the -pguide switch (on page 1-55), the compiler
associates all counters for this module with the session identifier
session-id.
•When used with a previously-gathered profile (a
.pgo file), the
compiler ignores the profile contents, unless they have the same
session-id identifier.
1-54VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
This is most useful when the same source file is being built in more than
one way (for example, different macro definitions, or for multiple processors) in the same application; each variant of the build can have a different
session-id associated with it, which means that the compiler will be able
to identify which parts of the gathered profile should be used when optimizing for the final build.
If each source file is only built in a single manner within the system (the
usual case), then the -pgo-session switch is not needed.
For more information, see “Using Profile-Guided Optimization” in
Chapter 2, Achieving Optimal Performance From C/C++ Source Code.
-pguide
The -pguide switch causes the compiler to add instrumentation for the
gathering of a profile (a .pgo file) as the first stage of performing profileguided optimization.
For more information, see “Using Profile-Guided Optimization” in
Chapter 2, Achieving Optimal Performance From C/C++ Source Code.
-pplist
The -pplistfilename (preprocessor listing) directs the preprocessor to
output a listing to the named file. When more than one source file is preprocessed, the listing file contains information about the last file
processed. The generated file contains raw source lines, information on
transitions into and out of include files, and diagnostics generated by the
Invoke this switch with the PGO session name text field located in
the VisualDSP++ Project Options dialog box, Compile page,
Profile-Guided Optimization category.
Invoke this switch with the Prepare application to create new pro-file check box located in the VisualDSP++ Project Options dialog
box, Compile page, Profile-Guided Optimization category.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-55
for SHARC Processors
Compiler Command-Line Interface
compiler. Each listing line begins with a key character that identifies its
type as shown in Table 1-9.
Table 1-9. Key Characters
CharacterMeaning
NNormal line of source
XExpanded line of source
SLine of source skipped by #if or #ifdef
LChange in source position
RDiagnostic message (remark)
WDiagnostic message (warning)
EDiagnostic message (error)
CDiagnostic message (catastrophic error)
-proc processor
The -proc processor (target processor) switch specifies the compiler produces code suitable for the specified processor. Refer to VisualDSP++
online Help for the list of supported SHARC processors. For example,
cc21k -proc ADSP-21161 -o bin\p1.doj p1.asm
If no target is specified with the -proc switch, the system uses the
When compiling with the
ADSP-21060 processor settings as a default.
-proc switch, the appropriate processor macro
as well as __ADSP21000__ are defined as 1. For example, __ADSP21060__
__ADSP21000__ are 1.
and
See also “-si-revision” on page 1-61 for more information on sili-
con revision of the specified processor.
1-56VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
-progress-rep-func
The -progress-rep-func switch provides feedback on the compiler’s
progress that may be useful when compiling and optimizing very large
source files. It issues a “warning” message each time the compiler starts
compiling a new function. The “warning” message is a remark that is disabled by default, and this switch enables the remark as a warning. The
switch is equivalent to -Wwarn=cc1472.
-progress-rep-opt
The -progress-rep-opt switch provides feedback on the compiler’s progress that may be useful when compiling and optimizing a very large,
complex function. It issues a “warning” message each time the compiler
starts a new optimization pass on the current function. The “warning”
message is a remark that is disabled by default, and this switch enables the
remark as a warning. The switch is equivalent to -Wwarn=cc1473.
-progress-rep-timeout
The -progress-rep-timeout switch issues a diagnostic message if the
compiler exceeds a time limit during compilation. This indicates the compiler is still operating, just taking a long time.
-progress-rep-timeout-secs secs
The -progress-rep-timeout-secs switch specifies how many seconds
must elapse during a compilation before the compiler issues a diagnostic
message about the length of time the compilation has used so far.
-R
The -Rdirectory[{:|,}directory … (add source directory) switch directs
the compiler to add the specified directory to the list of directories
searched for source files. On Windows platforms, multiple source directories are given as a colon, comma, or semicolon separated list.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-57
for SHARC Processors
Compiler Command-Line Interface
The compiler searches for the source files in the order specified on the
command line. The compiler searches the specified directories before
reverting to the current project directory. The
position-dependent on the command line. That is, it affects only source
files that follow the option.
-R directory option is
-R-
The -R- (disable source path) switch removes all directories from the standard search path for source files, effectively disabling this feature.
-reserve
The -reserve register[, register …] (reserve register) switch directs
the compiler not to use the specified registers. This guarantees that a
known set of registers are available for inline assembly code or linked
assembly modules. Separate each register name with a comma on the compiler command line.
You can reserve the following registers:
l8, m8, i8, b9, l9, m9, i9, ustat1, and ustat2 (as well as ustat3 and ustat4
on ADSP-211xx, ADSP-212xx, ADSP-213xx, and ADSP-214xx processors). When reserving an
corresponding I (index) register; reserving an L register without reserving
the corresponding
Source files whose file names begin with /, ./ or ../ (or Windows
equivalent) and contain drive specifiers (on Windows platforms)
are not affected by this option.
This option is position-dependent on the command line; it only
affects files following it.
b0, l0, m0, i0, b1, l1, m1, i1, b8,
L (length) register, you must reserve the
I register may result in execution problems.
1-58VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
-restrict-hardware-loops
The -restrict-hardware-loops maximum switch restricts the level of
nested hardware loops that the compiler generates. The default setting is
6, which is the maximum number of levels that the hardware supports.
-S
The -S (stop after compilation) switch directs cc21k to stop compilation
before running the assembler. The compiler outputs an assembly file
with an .s extension.
-s
The -s (strip debug information) switch directs the compiler to remove
debug information (symbol table and other items) from the output executable file during linking.
-sat-associative
The -sat-associative (saturating addition is associative) switch instructs
the compiler to consider saturating addition operations as associative:
(a+b)+c may be rewritten as a+(b+c), when the addition operator satu-
rates. The default is that saturating addition is not associative.
-save-temps
The -save-temps (save intermediate files) switch directs the compiler to
retain intermediate files, generated and normally removed as part of the
various compilation stages. These intermediate files are placed in the
–path-output specified output directory or the build directory if the
–path-output switch is not used. See Table 1-3 on page 1-8 for a list of
intermediate files.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-59
for SHARC Processors
Invoke this switch with the Save temporary files check box located
in the VisualDSP++ Project Options dialog box, Compile page,
General category.
Compiler Command-Line Interface
-section
The -sectionid=section_name[,id=section_name...] switch controls
the placement of types of data produced by the compiler. The data is
placed into the section “section_name” as specified on the command line.
The compiler currently supports the following section identifiers:
codeControls placement of machine instructions
Default is seg_pmco
dataControls placement of initialized variable data
Default is seg_dmda
pm_dataControls placement of initialized data declared with the _pm keyword
constdataControls placement of constant data
pm_constdataControls placement of constant data declared with the _pm keyword
bszControls placement of zero-initialized variable data
Default is
seg_dmda
stiControls placement of the static C++ class constructor “start” functions
Default is seg_pmco
For more information, see “Constructors and Destructors of Global Class
Instances” on page 1-313.
switchControls placement of jump-tables used to implement C/C++ switch
statements
stringsControls placement of string literals
vtblControls placement of the C++ virtual lookup tables
Default is seg_vtbl
vtableSynonym for vtbl
autoinitControls placement of data used to initialize aggregate autos
alldataControls placement of data, constdata, bss, strings and autoinit
all at once
1-60VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
Please note that
alldata is not a real section kind, but rather a placeholder
for data, constdata, bsz, strings and autoinit. Theferore,
Make sure that the section selected via the command line exists within the
.ldf file. (Refer to the “Linker” chapter in the VisualDSP++ 5.0 Linker
and Utilities Manual.)
-short-word-code
The -short-word-code switch has the same effect as compiling with the
-swc switch on page 1-63. It directs the compiler to generate instructions
of short word size (16/32/48-bits). This switch only applies when compiling code targeted for ADSP-214xx processors and is the default setting.
-show
The -show (display command line) switch shows the command-line arguments passed to cc21k, including expanded option files and environment
variables. This option allows you to ensure that command-line options
have been passed successfully.
-si-revision
The -si-revision version (silicon revision) switch directs the compiler
to build for a specific hardware revision (version). Any errata workarounds
available for the targeted silicon revision will be enabled. For more infor-
mation, see “Controlling Silicon Revision and Anomaly Workarounds
Within the Compiler” on page 1-86.
VisualDSP++ 5.0 C/C++ Compiler Manual 1-61
for SHARC Processors
Compiler Command-Line Interface
-signed-bitfield
The -signed-bitfield (make plain bit-fields signed) switch directs the
compiler to make bit-fields (which have not been declared with an explicit
signed or unsigned keyword) to be signed. This switch does not affect
plain one-bit bit-fields which are always unsigned. This is the default
mode. See also the -unsigned-bitfield switch (on page 1-65).
-structs-do-not-overlap
The -structs-do-not-overlap switch specifies that the source code being
compiled contains no structure copies such that the source and the destination memory regions overlap each other in a non-trivial way.
For example, in the statement
*p = *q;
where p and q are pointers to some structure type S, the compiler, by
default, always ensures that, after the assignment, the structure pointed to
by “p” contains an image of the structure pointed to by “q” prior to the
assignment. In the case where p and q are not identical (in which case the
assignment is trivial) but the structures pointed to by the two pointers
may overlap each other, doing this means that the compiler must use the
functionality of the C library function “memmove” rather than “memcpy”.
It is slower to use “
fore, if your source code does not contain such overlapping structure
copies, you can obtain higher performance by using the command-line
switch
1-62VisualDSP++ 5.0 C/C++ Compiler Manual
-structs-do-not-overlap.
Invoke this switch from the Structs/classes do not overlap check
box in the VisualDSP++ Project Options dialog box, Compile tab,
Language Settings category.
memmove” to copy data than it is to use “memcpy”. There-
for SHARC Processors
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.