ANALOG DEVICES W5.0 Compiler Manual

a
W 5.0
C/C++ Compiler Manual
for SHARC
®
Processors
Part Number
82-001963-02
Analog Devices, Inc. One Technology Way Norwood, Mass. 02062-9106
Copyright Information
© 2011 Analog Devices, Inc., ALL RIGHTS RESERVED. This docu­ment may not be reproduced in any form without prior, express written consent from Analog Devices, Inc.
Printed in the USA.
Disclaimer
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 impli­cation or otherwise under the patent rights of Analog Devices, Inc.
Trademark and Service Mark Notice
The Analog Devices logo, SHARC, and VisualDSP++ are registered trade­marks 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
Intended Audience ..................................................................... xxxi
Manual Contents ...................................................................... xxxii
What’s New in This Manual ...................................................... xxxii
Technical or Customer Support ................................................ xxxiii
Supported Processors ................................................................ xxxiv
Product Information ................................................................ xxxiv
Analog Devices Web Site .................................................... xxxiv
VisualDSP++ Online Documentation ................................. xxxv
Technical Library CD ......................................................... xxxvi
EngineerZone ..................................................................... xxxvi
Social Networking Web Sites ............................................. xxxvii
Notation Conventions ............................................................. xxxvii
VisualDSP++ 5.0 C/C++ Compiler Manual iii for SHARC Processors
Contents
COMPILER
C/C++ Compiler Overview ........................................................... 1-3
Compiler Command-Line Interface .............................................. 1-5
Running the Compiler ............................................................ 1-6
Compiler Command-Line Switches ......................................... 1-7
C/C++ Compiler Switch Summaries .................................... 1-7
C/C++ Mode Selection Switch Descriptions ...................... 1-20
-c89 ............................................................................. 1-20
-c99 ............................................................................. 1-20
-c++ ............................................................................. 1-20
C/C++ Compiler Common Switch Descriptions ................ 1-21
sourcefile ...................................................................... 1-21
-@ filename .................................................................. 1-21
-A name[tokens] ........................................................... 1-21
-add-debug-libpaths ...................................................... 1-22
-aligned-stack ............................................................... 1-23
-alttok ......................................................................... 1-23
-always-inline ............................................................... 1-24
-annotate ...................................................................... 1-24
-annotate-loop-instr ...................................................... 1-24
-auto-attrs .................................................................... 1-25
-build-lib ...................................................................... 1-25
-C ................................................................................ 1-25
-c ................................................................................. 1-25
iv VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Contents
-compatible-pm-dm ...................................................... 1-25
-const-read-write ........................................................... 1-25
-const-strings ................................................................ 1-26
-D ................................................................................ 1-26
-debug-types ................................................................. 1-26
-double-size[-32|-64] ..................................................... 1-27
-double-size-any ............................................................ 1-28
-dry .............................................................................. 1-28
-dryrun ......................................................................... 1-28
-E ................................................................................. 1-29
-ED .............................................................................. 1-29
-EE ............................................................................... 1-29
-eh ................................................................................ 1-29
-enum-is-int .................................................................. 1-30
-extra-keywords ............................................................. 1-30
-file-attr
name[=value] .................................................. 1-31
-flags ............................................................................. 1-31
-float-to-int ................................................................... 1-32
-force-circbuf ................................................................ 1-32
-fp-associative ............................................................... 1-32
-full-version .................................................................. 1-32
-fx-contract ................................................................... 1-33
-fx-rounding-mode-biased ............................................. 1-33
-fx-rounding-mode-truncation ....................................... 1-33
VisualDSP++ 5.0 C/C++ Compiler Manual v for SHARC Processors
Contents
-fx-rounding-mode-unbiased ......................................... 1-33
-g ................................................................................. 1-33
-glite ........................................................................... 1-34
-H ............................................................................... 1-34
-HH ............................................................................. 1-35
-h[elp] .......................................................................... 1-35
-I ................................................................................ 1-35
-I- ................................................................................ 1-36
-i .................................................................................. 1-36
-implicit-pointers .......................................................... 1-36
-include ....................................................................... 1-37
-ipa .............................................................................. 1-37
-L ................................................................................ 1-38
-l ................................................................................. 1-38
-list-workarounds .......................................................... 1-39
-M ............................................................................... 1-39
-MD ............................................................................ 1-39
-MM ............................................................................ 1-39
-Mo .............................................................................. 1-40
-Mt .............................................................................. 1-40
-map ............................................................................ 1-40
-mem ........................................................................... 1-40
-multiline ..................................................................... 1-40
-never-inline ................................................................. 1-41
vi VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Contents
-no-aligned-stack ........................................................... 1-41
-no-alttok ..................................................................... 1-41
-no-annotate ................................................................. 1-41
-no-annotate-loop-instr ................................................. 1-42
-no-auto-attrs ................................................................ 1-42
-no-builtin .................................................................... 1-42
-no-circbuf .................................................................... 1-43
-no-const-strings ........................................................... 1-43
-no-db .......................................................................... 1-43
-no-defs ........................................................................ 1-43
-no-eh ........................................................................... 1-43
-no-extra-keywords ........................................................ 1-44
-no-fp-associative .......................................................... 1-44
-no-fx-contract .............................................................. 1-44
-no-mem ....................................................................... 1-45
-no-multiline ................................................................ 1-45
-no-progress-rep-timeout ............................................... 1-45
-no-sat-associative ......................................................... 1-45
-no-saturation ............................................................... 1-46
-no-shift-to-add ............................................................ 1-46
-no-simd ....................................................................... 1-46
-no-std-ass .................................................................... 1-47
-no-std-def .................................................................... 1-47
-no-std-inc .................................................................... 1-47
VisualDSP++ 5.0 C/C++ Compiler Manual vii for SHARC Processors
Contents
-no-std-lib .................................................................... 1-47
-no-threads ................................................................... 1-47
-no-workaround ........................................................... 1-48
-normal-word-code ....................................................... 1-48
-nwc ............................................................................. 1-48
-O[0|1] ........................................................................ 1-48
-Oa .............................................................................. 1-49
-Og .............................................................................. 1-49
-Os ............................................................................... 1-49
-Ov .............................................................................. 1-49
-o ................................................................................ 1-51
-overlay ........................................................................ 1-52
-overlay-clobbers .......................................................... 1-52
-P ................................................................................. 1-53
-PP ............................................................................... 1-53
-path-{ asm | compiler | lib | link } ............................... 1-53
-path-install ................................................................. 1-53
-path-output ................................................................ 1-54
-path-temp .................................................................. 1-54
-pch ............................................................................. 1-54
-pchdir ........................................................................ 1-54
-pgo-session ................................................................. 1-54
-pguide ......................................................................... 1-55
-pplist ......................................................................... 1-55
viii VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Contents
-proc processor .............................................................. 1-56
-progress-rep-func ......................................................... 1-57
-progress-rep-opt ........................................................... 1-57
-progress-rep-timeout .................................................... 1-57
-progress-rep-timeout-secs secs ...................................... 1-57
-R ................................................................................. 1-57
-R- ............................................................................... 1-58
-reserve ......................................................................... 1-58
-restrict-hardware-loops ................................................. 1-59
-S ................................................................................. 1-59
-s .................................................................................. 1-59
-sat-associative .............................................................. 1-59
-save-temps ................................................................... 1-59
-section ......................................................................... 1-60
-short-word-code ........................................................... 1-61
-show ............................................................................ 1-61
-si-revision .................................................................... 1-61
-signed-bitfield .............................................................. 1-62
-structs-do-not-overlap .................................................. 1-62
-swc .............................................................................. 1-63
-syntax-only .................................................................. 1-63
-sysdefs ......................................................................... 1-63
-T ................................................................................ 1-63
-threads ........................................................................ 1-64
VisualDSP++ 5.0 C/C++ Compiler Manual ix for SHARC Processors
Contents
-time ............................................................................ 1-64
-U ............................................................................... 1-64
-unsigned-bitfield ......................................................... 1-65
-v ................................................................................. 1-65
-verbose ........................................................................ 1-66
-version ........................................................................ 1-66
-W ............................................................................... 1-66
-Werror-limit number ................................................... 1-67
-Werror-warnings ......................................................... 1-67
-Wremarks .................................................................... 1-67
-Wterse ......................................................................... 1-67
-w ................................................................................ 1-67
-warn-protos ................................................................. 1-68
-workaround ................................................................. 1-68
-write-files .................................................................... 1-68
-write-opts .................................................................... 1-69
-xref
filename .............................................................. 1-69
C Mode (MISRA) Compiler Switch Descriptions .............. 1-70
-misra ........................................................................... 1-70
-misra-linkdir ............................................................... 1-70
-misra-no-cross-module ................................................ 1-70
-misra-no-runtime ........................................................ 1-71
-misra-strict .................................................................. 1-71
-misra-suppress-advisory ............................................... 1-71
x VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Contents
-misra-testing ................................................................ 1-71
-Wmis_suppress ............................................................ 1-71
-Wmis_warn ................................................................. 1-72
C++ Mode Compiler Switch Descriptions .......................... 1-72
-anach ........................................................................... 1-72
-check-init-order ........................................................... 1-73
-extern-inline ................................................................ 1-74
-friend-injection ............................................................ 1-74
-full-dependency-inclusion ............................................ 1-74
-ignore-std .................................................................... 1-75
-no-anach ..................................................................... 1-75
-no-extern-inline ........................................................... 1-75
-no-friend-injection ....................................................... 1-76
-no-implicit-inclusion ................................................... 1-76
-no-rtti ......................................................................... 1-76
-no-std-templates .......................................................... 1-76
-rtti .............................................................................. 1-76
-std-templates ............................................................... 1-77
Environment Variables Used by the Compiler ........................ 1-77
Data Type and Data Type Sizes .............................................. 1-78
Integer Data Types ............................................................ 1-80
Floating-Point Data Types ................................................. 1-80
VisualDSP++ 5.0 C/C++ Compiler Manual xi for SHARC Processors
Contents
Optimization Control ........................................................... 1-81
Optimization Levels ......................................................... 1-81
Interprocedural Analysis ................................................... 1-84
Interaction With Libraries ............................................. 1-85
Controlling Silicon Revision and Anomaly Workarounds
Within the Compiler .......................................................... 1-86
Using the -si-revision Switch ............................................. 1-87
Using the -workaround Switch .......................................... 1-88
Using the -no-workaround Switch ..................................... 1-89
Interactions Between the Silicon Revision and
Workaround Switches .................................................... 1-89
Using Native Fixed-Point Types .................................................. 1-90
Fixed-Point Type Support ...................................................... 1-90
Native Fixed-Point Types ....................................................... 1-91
Native Fixed-Point Constants ................................................ 1-92
A Motivating Example .......................................................... 1-93
Fixed-Point Arithmetic Semantics .......................................... 1-94
Data Type Conversions and Fixed-Point Types ....................... 1-94
Bit-Pattern Conversion Functions: bitsfx and fxbits ................ 1-96
Arithmetic Operators for Fixed-Point Types ........................... 1-97
FX_CONTRACT ................................................................. 1-99
Rounding Behavior ............................................................. 1-101
xii VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Contents
Arithmetic Library Functions ............................................... 1-103
divifx .............................................................................. 1-104
idivfx .............................................................................. 1-105
fxdivi .............................................................................. 1-106
mulifx ............................................................................. 1-107
absfx ............................................................................... 1-108
roundfx .......................................................................... 1-108
countlsfx ......................................................................... 1-109
strtofxfx .......................................................................... 1-109
Fixed-Point I/O Conversion Specifiers ................................. 1-109
Setting the Rounding Mode ................................................. 1-111
Language Standards Compliance ............................................... 1-113
C Mode .............................................................................. 1-113
C++ Mode ........................................................................... 1-114
MISRA-C Compiler ................................................................. 1-115
MISRA-C Compiler Overview ............................................. 1-115
MISRA-C Compliance ........................................................ 1-116
Using the Compiler to Achieve Compliance ..................... 1-117
Rules Descriptions ............................................................... 1-120
C/C++ Compiler Language Extensions ...................................... 1-128
Function Inlining ................................................................ 1-133
Inlining and Optimization .............................................. 1-136
Inlining and Out-of-Line Copies ..................................... 1-136
VisualDSP++ 5.0 C/C++ Compiler Manual xiii for SHARC Processors
Contents
Inlining and Global asm Statements ................................ 1-137
Inlining and Sections ...................................................... 1-137
Variable Argument Macros .................................................. 1-138
Restricted Pointers .............................................................. 1-138
Variable-Length Array Support ............................................ 1-139
Non-Constant Initializer Support ........................................ 1-141
Designated Initializers ......................................................... 1-142
Hexadecimal Floating-Point Numbers ................................. 1-144
Declarations Mixed With Code ........................................... 1-145
Compound Literals ............................................................. 1-146
C++ Style Comments .......................................................... 1-147
Enumeration Constants That Are Not int Type .................... 1-147
Boolean Type Support Keywords (bool, true, false) .............. 1-147
The fract Native Fixed-Point Type ....................................... 1-148
Inline Assembly Language Support Keyword (asm) .............. 1-148
asm() Construct Syntax ................................................... 1-150
asm() Construct Syntax Rules ..................................... 1-152
asm() Construct Template Example ............................. 1-153
Assembly Construct Operand Description ....................... 1-154
Using long long Types in asm Constraints ....................... 1-160
Assembly Constructs With Multiple Instructions ............. 1-161
Assembly Construct Reordering and Optimization .......... 1-162
Assembly Constructs With Input and Output
Operands ..................................................................... 1-163
Assembly Constructs With Compile-Time Constants ...... 1-164
xiv VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Contents
Assembly Constructs and Flow Control ........................... 1-165
Guidelines on the Use of asm() Statements ...................... 1-165
Dual Memory Support Keywords (pm dm) .......................... 1-166
Memory Keywords and Assignments/
Type Conversions ......................................................... 1-169
Memory Keywords and Function Declarations/
Pointers ....................................................................... 1-170
Memory Keywords and Function Arguments ................... 1-171
Memory Keywords and Macros ....................................... 1-172
Bank Type Qualifiers ........................................................... 1-173
Placement Support Keyword (section) .................................. 1-174
Placement of Compiler-Generated Code and Data ............... 1-175
Long Identifiers ................................................................... 1-176
Preprocessor Generated Warnings ........................................ 1-176
Compiler Built-In Functions ................................................ 1-177
Access to System Registers .............................................. 1-177
Circular Buffer Built-In Functions ................................... 1-180
Circular Buffer Increment of an Index ......................... 1-181
Circular Buffer Increment of a Pointer ......................... 1-181
Compiler Performance Built-In Functions ....................... 1-182
Expected Behavior ....................................................... 1-182
Known Values ............................................................. 1-184
Fractional Built-In Functions .......................................... 1-185
Miscellaneous Built-In Function ...................................... 1-187
VisualDSP++ 5.0 C/C++ Compiler Manual xv for SHARC Processors
Contents
Pragmas .............................................................................. 1-187
Data Alignment Pragmas ................................................ 1-189
#pragma align num ..................................................... 1-189
#pragma alignment_region (alignopt) .......................... 1-191
#pragma pack (alignopt) .............................................. 1-192
#pragma pad (alignopt) ............................................... 1-193
Interrupt Handler Pragmas ............................................. 1-193
#pragma implicit_push_sts_handler ............................ 1-194
#pragma interrupt ...................................................... 1-194
#pragma interrupt_complete_nesting .......................... 1-195
#pragma interrupt_complete ....................................... 1-196
#pragma save_restore_40_bits ..................................... 1-196
#pragma save_restore_simd_40_bits
(SIMD SHARCs Only) ............................................ 1-197
Interrupt Pragmas and the Interrupt Vector Table ........ 1-197
Loop Optimization Pragmas ........................................... 1-198
#pragma SIMD_for .................................................... 1-199
#pragma all_aligned .................................................... 1-199
#pragma no_vectorization ........................................... 1-199
#pragma loop_count (min, max, modulo) .................... 1-200
#pragma loop_unroll N .............................................. 1-200
#pragma no_alias ........................................................ 1-203
#pragma vector_for .................................................... 1-203
xvi VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Contents
General Optimization Pragmas ........................................ 1-204
Function Side-Effect Pragmas .......................................... 1-205
#pragma alloc .............................................................. 1-206
#pragma const ............................................................. 1-206
#pragma misra_func(arg) ............................................. 1-207
#pragma noreturn ....................................................... 1-207
#pragma pgo_ignore .................................................... 1-207
#pragma pure .............................................................. 1-208
#pragma regs_clobbered string .................................... 1-209
#pragma regs_clobbered_call string .............................. 1-213
#pragma overlay .......................................................... 1-217
#pragma result_alignment (n) ...................................... 1-217
Class Conversion Optimization Pragmas .......................... 1-218
#pragma param_never_null param_name [ ... ] ............ 1-218
#pragma suppress_null_check ...................................... 1-219
Template Instantiation Pragmas ...................................... 1-221
#pragma instantiate instance ........................................ 1-222
#pragma do_not_instantiate instance ........................... 1-223
#pragma can_instantiate instance ................................. 1-223
Header File Control Pragmas ........................................... 1-223
#pragma hdrstop ......................................................... 1-223
#pragma no_implicit_inclusion ................................... 1-224
#pragma no_pch ......................................................... 1-225
VisualDSP++ 5.0 C/C++ Compiler Manual xvii for SHARC Processors
Contents
Fixed-Point Arithmetic Pragmas ...................................... 1-226
Inline Control Pragmas ................................................... 1-229
#pragma once ............................................................. 1-226
#pragma system_header .............................................. 1-226
#pragma FX_CONTRACT {ON|OFF} ....................... 1-227
#pragma FX_ROUNDING_MODE
{TRUNCATION|BIASED|UNBIASED} ................. 1-227
#pragma STDC FX_FULL_PRECISION
{ON|OFF|DEFAULT} ............................................. 1-228
#pragma STDC FX_FRACT_OVERFLOW
{SAT|DEFAULT} ..................................................... 1-228
#pragma always_inline ................................................ 1-229
#pragma inline ........................................................... 1-230
#pragma never_inline ................................................. 1-230
Linking Control Pragmas ................................................ 1-231
#pragma linkage_name identifier ................................. 1-231
#pragma core .............................................................. 1-231
#pragma retain_name ................................................ 1-236
#pragma section/#pragma default_section ................... 1-238
#pragma file_attr(“name[=value]”
[, “name[=value]” [...]]) ............................................ 1-242
#pragma weak_entry .................................................. 1-243
xviii VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Contents
Diagnostic Control Pragmas ............................................ 1-243
Modifying the Severity of Specific Diagnostics ............. 1-244
Modifying the Behavior of an Entire Class of
Diagnostics .............................................................. 1-245
Saving or Restoring the Current Behavior of All
Diagnostics .............................................................. 1-245
Memory Bank Pragmas ................................................... 1-246
#pragma code_bank(bankname) ................................... 1-247
#pragma data_bank(bankname) ................................... 1-247
#pragma stack_bank(bankname) .................................. 1-248
#pragma bank_memory_kind(bankname, kind) ............ 1-250
#pragma bank_read_cycles(bankname, cycles) ............... 1-250
#pragma bank_write_cycles(bankname, cycles) .............. 1-251
#pragma bank_optimal_width(bankname, width) ......... 1-252
Code Generation Pragmas ............................................... 1-253
#pragma avoid_anomaly_45 {on | off} ......................... 1-253
#pragma no_db_return ................................................ 1-253
Exceptions Table Pragma ................................................. 1-254
#pragma generate_exceptions_tables ............................ 1-254
GCC Compatibility Extensions ........................................... 1-256
Statement Expressions ..................................................... 1-256
Type Reference Support Keyword (Typeof) ...................... 1-258
GCC Generalized Lvalues ............................................... 1-259
Conditional Expressions with Missing Operands .............. 1-259
Zero-Length Arrays ......................................................... 1-260
VisualDSP++ 5.0 C/C++ Compiler Manual xix for SHARC Processors
Contents
GCC Variable Argument Macros ..................................... 1-260
Line Breaks in String Literals .......................................... 1-260
Arithmetic on Pointers to Void and Pointers to
Cast to Union ................................................................. 1-261
Ranges in Case Labels ..................................................... 1-261
Escape Character Constant ............................................. 1-261
Alignment Inquiry Keyword (__alignof__) ...................... 1-261
Keyword for Specifying Names in Generated
Function, Variable and Type Attribute Keyword
Unnamed struct/union Fields Within struct/unions ......... 1-263
Functions .................................................................... 1-261
Assembler (asm) ........................................................... 1-262
(__attribute__) ............................................................ 1-263
C++ Fractional Type Support .............................................. 1-264
Format of Fractional Literals ........................................... 1-264
Conversions Involving Fractional Values .......................... 1-265
Fractional Arithmetic Operations .................................... 1-265
Mixed Mode Operations ................................................. 1-266
Saturated Arithmetic ........................................................... 1-266
Support for 40-bit Arithmetic ............................................. 1-267
Using 40-bit Arithmetic in Compiled Code ..................... 1-268
Run-Time Library Functions That Use 40-bit
Arithmetic ................................................................... 1-269
Interrupt Support ........................................................... 1-270
xx VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Contents
SIMD Support .................................................................... 1-271
A Brief Introduction to SIMD Mode ............................... 1-271
What the Compiler Can Do Automatically ...................... 1-272
What Prevents the Compiler From Automatically
Exploiting SIMD Mode ................................................ 1-273
How to Help the Compiler Exploit SIMD Mode ............. 1-274
How to Prevent SIMD Code Generation ......................... 1-275
Accessing External Memory on ADSP-2126x and
ADSP-2136x Processors .................................................... 1-275
Link-Time Checking of Data Placement .......................... 1-275
Inline Functions for External Memory Access .................. 1-276
Support for Interrupts ......................................................... 1-276
Interrupt Dispatchers ...................................................... 1-277
Interrupts and Circular Buffering .................................... 1-281
Avoiding Self-Modifying Code ........................................ 1-281
Interrupt Nesting Restrictions on ADSP-211xx/212xx/
213xx/214xx Processors ................................................ 1-282
Restriction on Use of Super-Fast Dispatcher on
ADSP-2106x Processors ............................................... 1-282
Restrictions on Using Normal and Circular Buffer
Interrupt Dispatchers on ADSP-2136x Processors ......... 1-284
Migrating .ldf Files From Previous VisualDSP++
Installations ...................................................................... 1-284
C++ Support Tables (ctor, gdt) ........................................ 1-285
ADSP-21375 Memory Map ............................................ 1-287
VisualDSP++ 5.0 C/C++ Compiler Manual xxi for SHARC Processors
Contents
C++ Run-Time Libraries Rationalization ......................... 1-288
Fixed-Point I/O Support ................................................. 1-288
Preprocessor Features ................................................................ 1-289
Predefined Preprocessor Macros ........................................... 1-290
Writing Macros ................................................................... 1-297
Compound Macros ......................................................... 1-297
C/C++ Run-Time Model and Environment ............................... 1-300
C/C++ Run-Time Environment ........................................... 1-300
Memory Usage ............................................................... 1-302
Program Memory Code Storage .................................. 1-304
Data Memory Data Storage ......................................... 1-305
Program Memory Data Storage ................................... 1-305
Run-Time Stack Storage ............................................. 1-306
Run-Time Heap Storage ............................................ 1-306
Initialization Data Storage ......................................... 1-307
Run-Time Header Storage ........................................... 1-308
Memory Allocation for Stack and Heap on ADSP-2106x,
ADSP-2116x, and ADSP-2126x Processors .................. 1-310
Example of Heap/Stack Memory Allocation ................ 1-311
Measuring the Performance of the Compiler .................... 1-312
Constructors and Destructors of Global Class Instances ....... 1-313
Constructors, Destructors and Memory Placement .......... 1-314
Support for argv/argc .......................................................... 1-315
xxii VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Contents
Using Multiple Heaps .......................................................... 1-316
Declaring a Heap ............................................................ 1-317
Heap Identifiers .............................................................. 1-319
Allocating C++ STL Objects to a Non-Default Heap ....... 1-319
Using Alternate Heaps With the Standard Interface ......... 1-322
Using the Alternate Heap Interface .................................. 1-323
C++ Run-Time Support for the Alternate Heap
Interface ................................................................... 1-324
Example C Programs ....................................................... 1-325
Compiler Registers ............................................................. 1-327
Miscellaneous Information About Registers ..................... 1-327
User Registers ................................................................. 1-328
Call Preserved Registers ................................................... 1-329
Scratch Registers ............................................................. 1-330
Stack Registers ................................................................ 1-331
Alternate Registers ......................................................... 1-331
Managing the Stack ......................................................... 1-332
Transferring Function Arguments and Return Value ......... 1-338
Passing a C++ Class Instance ........................................... 1-341
Using Data Storage Formats ............................................ 1-341
fract Data Representation ................................................ 1-344
Using the Run-Time Header ........................................... 1-346
VisualDSP++ 5.0 C/C++ Compiler Manual xxiii for SHARC Processors
Contents
C/C++ and Assembly Interface .................................................. 1-347
Calling Assembly Subroutines From C/C++ Programs .......... 1-347
Calling C/C++ Functions From Assembly Programs ............. 1-350
Using Mixed C/C++ and Assembly Support Macros ......... 1-353
entry .......................................................................... 1-353
exit ............................................................................. 1-353
leaf_entry ................................................................... 1-354
leaf_exit ..................................................................... 1-354
ccall(x) ....................................................................... 1-354
reads(x) ...................................................................... 1-354
puts=x ........................................................................ 1-354
gets(x) ........................................................................ 1-354
alter(x) ....................................................................... 1-355
save_reg ...................................................................... 1-355
restore_reg .................................................................. 1-355
Using Mixed C/C++ and Assembly Naming
Conventions ................................................................ 1-357
Implementing C++ Member Functions in Assembly
Language ..................................................................... 1-359
Writing C/C++ Callable SIMD Subroutines .................... 1-361
C++ Programming Examples ............................................... 1-362
Using Fract Support ........................................................ 1-363
Using Complex Support ................................................. 1-364
xxiv VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Contents
Mixed C/C++/Assembly Programming Examples .................. 1-365
Using Inline Assembly (Add) ........................................... 1-367
Using Macros to Manage the Stack .................................. 1-367
Using Scratch Registers (Dot Product) ............................. 1-369
Using Void Functions (Delay) ......................................... 1-370
Using the Stack for Arguments (Add 5) ........................... 1-372
Using Registers for Arguments and Return (Add 2) .......... 1-373
Using Non-Leaf Routines That Make Calls (RMS) .......... 1-374
Using Call Preserved Registers (Pass Array) ...................... 1-376
Exceptions Tables in Assembly Routines ............................... 1-378
Compiler C++ Template Support ............................................... 1-381
Template Instantiation ......................................................... 1-381
Implicit Instantiation ...................................................... 1-382
Exported Templates ......................................................... 1-383
Generated Template Files ................................................ 1-384
Identifying Un-Instantiated Templates ............................. 1-385
File Attributes ........................................................................... 1-387
Automatically-Applied Attributes ......................................... 1-388
Content Attributes .......................................................... 1-389
FuncName Attributes ...................................................... 1-389
Encoding Attributes ........................................................ 1-390
Default LDF Placement ....................................................... 1-390
VisualDSP++ 5.0 C/C++ Compiler Manual xxv for SHARC Processors
Contents
Sections Versus Attributes ................................................... 1-391
Granularity ..................................................................... 1-391
“Hard” Versus “Soft” ...................................................... 1-392
Number of Values ........................................................... 1-392
Using Attributes .................................................................. 1-393
Example 1 ...................................................................... 1-393
Example 2 ...................................................................... 1-395
ACHIEVING OPTIMAL PERFORMANCE FROM C/C++
SOURCE CODE
General Guidelines ....................................................................... 2-2
How the Compiler Can Help .................................................. 2-3
Using the Compiler Optimizer ............................................ 2-4
Using Compiler Diagnostics ............................................... 2-4
Warnings and Remarks ................................................... 2-5
Assembly Annotations ..................................................... 2-7
Using the Statistical Profiler ................................................ 2-7
Using Profile-Guided Optimization .................................... 2-8
Using Profile-Guided Optimization With a Simulator ..... 2-8
Using Profile-Guided Optimization With
Non-Simulatable Applications .................................... 2-10
Profile-Guided Optimization and Multiple
Source Uses ............................................................... 2-10
Profile-Guided Optimization and the -Ov Switch .......... 2-11
xxvi VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Contents
Profile-Guided Optimization and Multiple PGO
Data Sets .................................................................... 2-11
When to Use Profile-Guided Optimization .................... 2-12
Using Interprocedural Optimization .................................. 2-12
Data Types ............................................................................ 2-13
Avoiding Emulated Arithmetic .......................................... 2-14
Getting the Most From IPA ................................................... 2-15
Initialize Constants Statically ............................................. 2-16
Dual Word-Aligning Your Data ......................................... 2-17
Using __builtin_aligned .................................................... 2-18
Avoiding Aliases ................................................................ 2-20
Indexed Arrays Versus Pointers ............................................... 2-22
Trying Pointer and Indexed Styles ...................................... 2-23
Using Function Inlining ....................................................... 2-23
Using Inline asm Statements .................................................. 2-24
Memory Usage ...................................................................... 2-25
Improving Conditional Code ...................................................... 2-27
Loop Guidelines ......................................................................... 2-28
Keeping Loops Short ............................................................. 2-28
Avoiding Unrolling Loops ...................................................... 2-29
Avoiding Loop-Carried Dependencies .................................... 2-29
Avoiding Loop Rotation by Hand .......................................... 2-30
Avoiding Complex Array Indexing ......................................... 2-32
Inner Loops vs. Outer Loops .................................................. 2-32
Avoiding Conditional Code in Loops ..................................... 2-33
VisualDSP++ 5.0 C/C++ Compiler Manual xxvii for SHARC Processors
Contents
Avoiding Placing Function Calls in Loops .............................. 2-34
Avoiding Non-Unit Strides .................................................... 2-34
Loop Control ........................................................................ 2-35
Using the Restrict Qualifier ................................................... 2-36
Avoiding Long Latencies ....................................................... 2-37
Using Built-In Functions in Code Optimization .......................... 2-38
Using System Support Built-In Functions .............................. 2-38
Using Circular Buffers ........................................................... 2-40
Smaller Applications: Optimizing for Code Size .......................... 2-42
Using Pragmas for Optimization ................................................. 2-43
Function Pragmas ................................................................. 2-44
#pragma alloc ................................................................... 2-44
#pragma const .................................................................. 2-45
#pragma pure ................................................................... 2-45
#pragma result_alignment ................................................. 2-45
#pragma regs_clobbered .................................................... 2-46
#pragma optimize_
{off|for_speed|for_space|as_cmd_line} ............................ 2-48
Loop Optimization Pragmas .................................................. 2-49
#pragma loop_count ......................................................... 2-49
#pragma no_vectorization ................................................. 2-50
#pragma vector_for ........................................................... 2-50
#pragma SIMD_for .......................................................... 2-51
#pragma all_aligned .......................................................... 2-51
#pragma no_alias .............................................................. 2-52
xxviii VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Contents
Useful Optimization Switches ...................................................... 2-53
How Loop Optimization Works .................................................. 2-54
Terminology .......................................................................... 2-54
Clobbered Register ............................................................ 2-54
Live Register ..................................................................... 2-55
Spill .................................................................................. 2-55
Scheduling ........................................................................ 2-55
Loop Kernel ...................................................................... 2-56
Loop Prolog ...................................................................... 2-56
Loop Epilog ...................................................................... 2-56
Loop Invariant .................................................................. 2-56
Hoisting ........................................................................... 2-57
Sinking ............................................................................. 2-57
Loop Optimization Concepts ................................................. 2-57
Software Pipelining ........................................................... 2-58
Loop Rotation .................................................................. 2-59
Loop Vectorization ............................................................ 2-61
Modulo Scheduling ........................................................... 2-63
Initiation Interval (II) and the Kernel ............................ 2-65
Minimum Initiation Interval Due to Resources
(Res MII) ................................................................... 2-68
Minimum Initiation Interval Due to Recurrences
(Rec MII) ................................................................... 2-68
Stage Count (SC) .......................................................... 2-69
VisualDSP++ 5.0 C/C++ Compiler Manual xxix for SHARC Processors
Variable Expansion and MVE Unroll ............................. 2-71
Trip Count ................................................................... 2-76
A Worked Example ............................................................... 2-77
Assembly Optimizer Annotations ................................................ 2-80
Global Information ............................................................... 2-81
Procedure Statistics ............................................................... 2-83
Instruction Annotations ........................................................ 2-88
Loop Identification ............................................................... 2-88
Loop Identification Annotations ....................................... 2-89
File Position ..................................................................... 2-93
Vectorization ......................................................................... 2-96
Loop Flattening ................................................................ 2-97
Vectorization Annotations ................................................. 2-99
Modulo Scheduling Information ......................................... 2-101
Annotations for Modulo Scheduled Instructions .............. 2-101
Warnings, Failure Messages and Advice ................................ 2-107
Analyzing Your Application ....................................................... 2-111
Stack Overflow Detection ................................................... 2-111
The Stack Overflow Detection Facility ............................ 2-113
INDEX
xxx VisualDSP++ 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 com­mand 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 inte­ger 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 free­standing implementation of the ISO/IEC14882:2003 C++ standard (“C++ 2003”). See “Language Standards Compliance” on
page 1-113 for more information.
xxxii VisualDSP++ 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 infor­mation, 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 pro­vides 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
http://www.analog.com/processors/technical_support
E-mail tools questions to
processor.tools.support@analog.com
E-mail processor questions to
processor.support@analog.com (World wide support) processor.europe@analog.com (Europe support) processor.china@analog.com (China support)
Phone questions to 1-800-ANALOGD
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-per­formance 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.
xxxiv VisualDSP++ 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 infor­mation 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
.chm Help system files and manuals in Microsoft help format
.htm or .html
.pdf VisualDSP++ 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, Visu­alDSP++ 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.
xxxvi VisualDSP++ 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.
Example Description
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-
.
filename Non-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
SECTION Commands, 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
Example Description
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.
xxxviii VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors

1 COMPILER

The C/C++ compiler (cc21k) is part of Analog Devices development soft­ware 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
processors” ISO/IEC draft technical report TR 18037.
“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 stan­dard 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 stan­dard 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-2 VisualDSP++ 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 ver­sions 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++ envi­ronment 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 com­piler. 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 stan­dard (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 refer­ence 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 lan­guage 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-4 VisualDSP++ 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 com­mand 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 writ­ten 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:
cc21k [-switch [-switch …] sourcefile [sourcefile …]]
Table 1-1 describes these syntax elements.
Table 1-1. cc21k Command Line Syntax
Command Element
cc21k Name of the compiler program for SHARC processors.
-switch Switch (or switches) to process.
sourceFile Name 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 (start­ing with two slashes and a network name). If the name contains spaces, enclose it in straight quotes; for example, "long file name.c"
1-6 VisualDSP++ 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 Name Description
-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 Name Description
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-8 VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch Name Description
-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 Name Description
-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 asso­ciative
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 pro­cesses 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-10 VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch Name Description
-implicit-pointers
(on page 1-36)
-include filename
(on page 1-37)
-ipa
(on page 1-37)
Demotes incompatible-pointer-type errors into discre­tionary 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 interpreta­tion
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 Name Description
-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 con­taining 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-12 VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch Name Description
-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 Name Description
-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 spec­ified compilation tool (assembler, compiler, librarian, or linker, respectively)
Uses the specified directory as the location of all com­pilation tools
-path-output directory (
on page 1-54)
Specifies the location of non-temporary files
1-14 VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch Name Description
-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 pro­file-guided optimization
Adds instrumentation for the gathering of a profile as the first stage of performing profile-guided optimiza­tion
Outputs a raw preprocessed listing to the specified file
Specifies that the compiler should produce code suit­able 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 com­pilation 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 Name Description
-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” seman­tics, 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-16 VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Table 1-3. C/C++ Compiler Common Switches (Cont’d)
Switch Name Description
-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 infor­mation 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 informa­tion
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 hard­ware 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 Name Description
-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 Name Description
-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-18 VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Table 1-5. C++ Mode Compiler Switches
Switch Name Description
-anach
(on page 1-72)
-check-init-order
(on page 1-73)
Supports some language features (anachronisms) that are prohib­ited by the C++ standard but still in common use
Adds run-time checking to the generated code highlighting poten­tial uninitialized external objects.
Compiler
-extern-inline
(on page 1-74)
-friend-injection
(on page 1-74)
-full-dependency­inclusion
(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 stan­dard, 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 exten­sion 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. Sup­port 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 key­words. 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-20 VisualDSP++ 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 prepro­cessor directive. The following assertions are predefined in Table 1-6.
Table 1-6. Predefined Assertions
Assertion Value
system
machine adsp21xxx
cpu adsp21xxx
compiler cc21k
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 cer­tain 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-22 VisualDSP++ 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 oper­ator keywords in C++ source files (Table 1-7).
Table 1-7. Alternative Operator Keywords
Keyword Equivalent
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 addi­tional 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-24 VisualDSP++ 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 auto­matic 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 dm­and
pm-qualified pointers as assignment-compatible.
-const-read-write
The -const-read-write switch directs the compiler to specify that con­stants 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 -D macro[=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 pro­cesses 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-26 VisualDSP++ 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 (dou­ble 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 val­ues 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-28 VisualDSP++ 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 func­tion 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 enumera­tion. 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-30 VisualDSP++ 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 mul­tiple 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
Option Tool
-flags-asm Assembler
-flags-compiler Compiler executable
-flags-lib Library Builder (elfar.exe)
-flags-link
-flags-mem Memory 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 per­forms 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 dis­play 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-32 VisualDSP++ 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 out­put 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 capabil­ities, 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-34 VisualDSP++ 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 preproces­sor 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 -I directory [{,|;} 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 speci­fied 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 directo­ries 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 com­mand 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 com­piling in C++ mode.
The -I switch removes the directory containing the current input file from the include directory list.
1-36 VisualDSP++ 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 -include filename (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 sep­arately. 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 -L directory[{;|,}directory…] (library search directory) switch directs the compiler to append the directory to the search path for library files.
-l
The -l library (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-38 VisualDSP++ 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 dis­plays 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 com­pile 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 -Mo filename (preprocessor output file) switch directs the compiler to use filename for the output of –MD or –ED switches.
-Mt
The -Mt name (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 -map filename (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 con­trolled 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-40 VisualDSP++ 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 com­piler 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 com­piler not to annotate assembly files generated by the compiler. The default behavior is that whenever optimizations are enabled all assembly files gen­erated 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 addi­tional 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-42 VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
-no-circbuf
The -no-circbuf (no circular buffer) switch disables the automatic gener­ation 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 lit­erals 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 direc­tories, 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++ lan­guages. 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-44 VisualDSP++ 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 com­piler 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 dia­log 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 compi­lations) 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 associa­tive. 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 gener­ation check box located in the VisualDSP++ Project Options
dialog box, Compile page, Processor (1) category.
1-46 VisualDSP++ 5.0 C/C++ Compiler Manual
for SHARC Processors
Compiler
-no-std-ass
The -no-std-ass (disable standard assertions) switch prevents the com­piler 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 com­piler 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 dia­log 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-workaround workaround_id (disable avoidance of specific errata) switch disables compiler code generator workarounds for specific hard­ware 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 tar­geted 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-48 VisualDSP++ 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 optimi­zations 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 -Ov num (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
0 100
Infinity
Optimize for space
Limit line
For any given optimization, the compiler modifies the code being gener­ated. 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 demon­strates this relationship.
1-50 VisualDSP++ 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 profile­guided optimization, where accurate execution counts are available. With­out 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 -o filename (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 propaga­tion 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-clobbers clobbered-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 argu­ment to #pragma regs_clobbered, except that individual components of the list may also be separated by commas.
Examples:
cc21k -O t.c -overlay -overlay-clobbers r3,m4,r5 cc21k -O t.c -overlay -overlay-clobbers Dscratch cc21k -O t.c -overlay -overlay-clobbers "r3 m4;r5"
1-52 VisualDSP++ 5.0 C/C++ Compiler Manual
Whitespace and semi-colons are valid separators for the compo­nents 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 pre­processor 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 multi­ple 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-temp directory (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 automati­cally 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 -pchdir directory (locate PCHRepository) switch specifies the loca­tion of an alternative PCHRepository for storing and invocation of precompiled header files. If the directory does not exist, the compiler cre­ates it. Note that -o (output) does not influence the -pchdir option.
-pgo-session
The -pgo-session session-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-54 VisualDSP++ 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 proces­sors) 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 opti­mizing 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 profile­guided optimization.
For more information, see “Using Profile-Guided Optimization” in Chapter 2, Achieving Optimal Performance From C/C++ Source Code.
-pplist
The -pplist filename (preprocessor listing) directs the preprocessor to output a listing to the named file. When more than one source file is pre­processed, 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
Character Meaning
N Normal line of source
X Expanded line of source
S Line of source skipped by #if or #ifdef
L Change in source position
R Diagnostic message (remark)
W Diagnostic message (warning)
E Diagnostic message (error)
C Diagnostic message (catastrophic error)
-proc processor
The -proc processor (target processor) switch specifies the compiler pro­duces 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-56 VisualDSP++ 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 dis­abled 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 prog­ress 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 com­piler 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 -R directory[{:|,}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 directo­ries 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 stan­dard 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 com­piler 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 proces­sors). 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-58 VisualDSP++ 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 execut­able 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 -section id=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:
code Controls placement of machine instructions
Default is seg_pmco
data Controls placement of initialized variable data
Default is seg_dmda
pm_data Controls placement of initialized data declared with the _pm keyword
constdata Controls placement of constant data
pm_constdata Controls placement of constant data declared with the _pm keyword
bsz Controls placement of zero-initialized variable data
Default is
seg_dmda
sti Controls 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.
switch Controls placement of jump-tables used to implement C/C++ switch
statements
strings Controls placement of string literals
vtbl Controls placement of the C++ virtual lookup tables
Default is seg_vtbl
vtable Synonym for vtbl
autoinit Controls placement of data used to initialize aggregate autos
alldata Controls placement of data, constdata, bss, strings and autoinit
all at once
1-60 VisualDSP++ 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,
-section alldata=X
is equivalent to
-section data=X -section constdata=X -section bsz=X
-section strings=X -section autoinit=X
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 compil­ing code targeted for ADSP-214xx processors and is the default setting.
-show
The -show (display command line) switch shows the command-line argu­ments 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 desti­nation 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-62 VisualDSP++ 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...