SPRU514Z
July 2001 – October 2023
SM320F28335-EP
1
Read This First
About This Manual
Notational Conventions
Related Documentation
Related Documentation From Texas Instruments
Trademarks
1
Introduction to the Software Development Tools
1.1
Software Development Tools Overview
1.2
Compiler Interface
1.3
ANSI/ISO Standard
1.4
Output Files
1.5
Utilities
2
Using the C/C++ Compiler
2.1
About the Compiler
2.2
Invoking the C/C++ Compiler
2.3
Changing the Compiler's Behavior with Options
2.3.1
Linker Options
2.3.2
Frequently Used Options
2.3.3
Miscellaneous Useful Options
2.3.4
Run-Time Model Options
2.3.5
Symbolic Debugging and Profiling Options
2.3.6
Specifying Filenames
2.3.7
Changing How the Compiler Interprets Filenames
2.3.8
Changing How the Compiler Processes C Files
2.3.9
Changing How the Compiler Interprets and Names Extensions
2.3.10
Specifying Directories
2.3.11
Assembler Options
2.3.12
Deprecated Options
2.4
Controlling the Compiler Through Environment Variables
2.4.1
Setting Default Compiler Options (C2000_C_OPTION)
2.4.2
Naming One or More Alternate Directories (C2000_C_DIR)
2.5
Controlling the Preprocessor
2.5.1
Predefined Macro Names
2.5.2
The Search Path for #include Files
2.5.2.1
Adding a Directory to the #include File Search Path (--include_path Option)
2.5.3
Support for the #warning and #warn Directives
2.5.4
Generating a Preprocessed Listing File (--preproc_only Option)
2.5.5
Continuing Compilation After Preprocessing (--preproc_with_compile Option)
2.5.6
Generating a Preprocessed Listing File with Comments (--preproc_with_comment Option)
2.5.7
Generating Preprocessed Listing with Line-Control Details (--preproc_with_line Option)
2.5.8
Generating Preprocessed Output for a Make Utility (--preproc_dependency Option)
2.5.9
Generating a List of Files Included with #include (--preproc_includes Option)
2.5.10
Generating a List of Macros in a File (--preproc_macros Option)
2.6
Passing Arguments to main()
2.7
Understanding Diagnostic Messages
2.7.1
Controlling Diagnostic Messages
2.7.2
How You Can Use Diagnostic Suppression Options
2.8
Other Messages
2.9
Generating Cross-Reference Listing Information (--gen_cross_reference_listing Option)
2.10
Generating a Raw Listing File (--gen_preprocessor_listing Option)
2.11
Using Inline Function Expansion
2.11.1
Inlining Intrinsic Operators
2.11.2
Inlining Restrictions
2.11.3
Unguarded Definition-Controlled Inlining
2.11.3.1
Using the Inline Keyword
2.11.4
Guarded Inlining and the _INLINE Preprocessor Symbol
2.11.4.1
Header File string.h
2.11.4.2
Library Definition File
2.12
Using Interlist
2.13
About the Application Binary Interface
2.14
Enabling Entry Hook and Exit Hook Functions
2.15
Live Firmware Update (LFU)
3
Optimizing Your Code
3.1
Invoking Optimization
3.2
Controlling Code Size Versus Speed
3.3
Performing File-Level Optimization (--opt_level=3 option)
3.3.1
Creating an Optimization Information File (--gen_opt_info Option)
3.4
Program-Level Optimization (--program_level_compile and --opt_level=3 options)
3.4.1
Controlling Program-Level Optimization (--call_assumptions Option)
3.4.2
Optimization Considerations When Mixing C/C++ and Assembly
3.5
Automatic Inline Expansion (--auto_inline Option)
3.6
Link-Time Optimization (--opt_level=4 Option)
3.6.1
Option Handling
3.6.2
Incompatible Types
3.7
Using Feedback Directed Optimization
3.7.1
Feedback Directed Optimization
3.7.1.1
Phase 1 -- Collect Program Profile Information
3.7.1.2
Phase 2 -- Use Application Profile Information for Optimization
3.7.1.3
Generating and Using Profile Information
3.7.1.4
Example Use of Feedback Directed Optimization
3.7.1.5
The .ppdata Section
3.7.1.6
Feedback Directed Optimization and Code Size Tune
3.7.1.7
Instrumented Program Execution Overhead
3.7.1.8
Invalid Profile Data
3.7.2
Profile Data Decoder
3.7.3
Feedback Directed Optimization API
3.7.4
Feedback Directed Optimization Summary
3.8
Using Profile Information to Analyze Code Coverage
3.8.1
Code Coverage
3.8.1.1
Phase1 -- Collect Program Profile Information
3.8.1.2
Phase 2 -- Generate Code Coverage Reports
3.8.2
Related Features and Capabilities
3.8.2.1
Path Profiler
3.8.2.2
Analysis Options
3.8.2.3
Environment Variables
3.9
Special Considerations When Using Optimization
3.9.1
Use Caution With asm Statements in Optimized Code
3.9.2
Use the Volatile Keyword for Necessary Memory Accesses
3.9.2.1
Use Caution When Accessing Aliased Variables
3.9.2.2
Use the --aliased_variables Option to Indicate That the Following Technique Is Used
3.9.2.3
On FPU Targets Only: Use restrict Keyword to Indicate That Pointers Are Not Aliased
3.9.2.3.1
Use of the restrict Type Qualifier With Pointers
3.9.2.3.2
Use of the restrict Type Qualifier With Pointers
3.10
Using the Interlist Feature With Optimization
3.11
Data Page (DP) Pointer Load Optimization
3.12
Debugging and Profiling Optimized Code
3.12.1
Profiling Optimized Code
3.13
Increasing Code-Size Optimizations (--opt_for_space Option)
3.14
Compiler Support for Re-Entrant VCU Code
3.15
Compiler Support for Generating DMAC Instructions
3.15.1
Automatic Generation of DMAC Instructions
3.15.2
Assertions to Specify Data Address Alignment
3.15.3
__dmac Intrinsic
3.16
What Kind of Optimization Is Being Performed?
3.16.1
Cost-Based Register Allocation
3.16.2
Alias Disambiguation
3.16.3
Branch Optimizations and Control-Flow Simplification
3.16.4
Data Flow Optimizations
3.16.5
Expression Simplification
3.16.6
Inline Expansion of Functions
3.16.7
Function Symbol Aliasing
3.16.8
Induction Variables and Strength Reduction
3.16.9
Loop-Invariant Code Motion
3.16.10
Loop Rotation
3.16.11
Instruction Scheduling
3.16.12
Register Variables
3.16.13
Register Tracking/Targeting
3.16.14
Tail Merging
3.16.15
Autoincrement Addressing
3.16.16
Removing Comparisons to Zero
3.16.17
RPTB Generation (for FPU Targets Only)
4
Linking C/C++ Code
4.1
Invoking the Linker Through the Compiler (-z Option)
4.1.1
Invoking the Linker Separately
4.1.2
Invoking the Linker as Part of the Compile Step
4.1.3
Disabling the Linker (--compile_only Compiler Option)
4.2
Linker Code Optimizations
4.2.1
Generating Function Subsections (--gen_func_subsections Compiler Option)
4.2.2
Generating Aggregate Data Subsections (--gen_data_subsections Compiler Option)
4.3
Controlling the Linking Process
4.3.1
Including the Run-Time-Support Library
4.3.1.1
Automatic Run-Time-Support Library Selection
4.3.1.1.1
Using the --issue_remarks Option
4.3.1.2
Manual Run-Time-Support Library Selection
4.3.1.3
Library Order for Searching for Symbols
4.3.2
Run-Time Initialization
4.3.3
Initialization by the Interrupt Vector
4.3.4
Global Object Constructors
4.3.5
Specifying the Type of Global Variable Initialization
4.3.6
Specifying Where to Allocate Sections in Memory
4.3.7
A Sample Linker Command File
4.4
Linking C28x and C2XLP Code
5
Post-Link Optimizer
5.1
The Post-Link Optimizer’s Role in the Software Development Flow
5.2
Removing Redundant DP Loads
5.3
Tracking DP Values Across Branches
5.4
Tracking DP Values Across Function Calls
5.5
Other Post-Link Optimizations
5.6
Controlling Post-Link Optimizations
5.6.1
Excluding Files (-ex Option)
5.6.2
Controlling Post-Link Optimization Within an Assembly File
5.6.3
Retaining Post-Link Optimizer Output (--keep_asm Option)
5.6.4
Disable Optimization Across Function Calls (-nf Option )
5.6.5
Annotating Assembly with Advice (--plink_advice_only option)
5.7
Restrictions on Using the Post-Link Optimizer
5.8
Naming the Outfile (--output_file Option)
6
C/C++ Language Implementation
6.1
Characteristics of TMS320C28x C
6.1.1
Implementation-Defined Behavior
6.2
Characteristics of TMS320C28x C++
6.3
Data Types
6.3.1
Size of Enum Types
6.3.2
Support for 64-Bit Integers
6.3.3
C28x double and long double Floating-Point Types
6.4
File Encodings and Character Sets
6.5
Keywords
6.5.1
The const Keyword
6.5.2
The __cregister Keyword
6.5.3
The __interrupt Keyword
6.5.4
The restrict Keyword
6.5.5
The volatile Keyword
6.6
C++ Exception Handling
6.7
Register Variables and Parameters
6.8
The __asm Statement
6.9
Pragma Directives
6.9.1
The CALLS Pragma
6.9.2
The CLINK Pragma
6.9.3
The CODE_ALIGN Pragma
6.9.4
The CODE_SECTION Pragma
6.9.5
The DATA_ALIGN Pragma
6.9.6
The DATA_SECTION Pragma
6.9.6.1
Using the DATA_SECTION Pragma C Source File
6.9.6.2
Using the DATA_SECTION Pragma C++ Source File
6.9.6.3
Using the DATA_SECTION Pragma Assembly Source File
6.9.7
The Diagnostic Message Pragmas
6.9.8
The FAST_FUNC_CALL Pragma
6.9.9
The FORCEINLINE Pragma
6.9.10
The FORCEINLINE_RECURSIVE Pragma
6.9.11
The FUNC_ALWAYS_INLINE Pragma
6.9.12
The FUNC_CANNOT_INLINE Pragma
6.9.13
The FUNC_EXT_CALLED Pragma
6.9.14
The FUNCTION_OPTIONS Pragma
6.9.15
The INTERRUPT Pragma
6.9.16
The LOCATION Pragma
6.9.17
The MUST_ITERATE Pragma
6.9.17.1
The MUST_ITERATE Pragma Syntax
6.9.17.2
Using MUST_ITERATE to Expand Compiler Knowledge of Loops
6.9.18
The NOINIT and PERSISTENT Pragmas
6.9.19
The NOINLINE Pragma
6.9.20
The NO_HOOKS Pragma
6.9.21
The once Pragma
6.9.22
The RETAIN Pragma
6.9.23
The SET_CODE_SECTION and SET_DATA_SECTION Pragmas
6.9.24
The UNROLL Pragma
6.9.25
The WEAK Pragma
6.10
The _Pragma Operator
6.11
Application Binary Interface
6.12
Object File Symbol Naming Conventions (Linknames)
6.13
Initializing Static and Global Variables in COFF ABI Mode
6.13.1
Initializing Static and Global Variables With the Linker
6.13.2
Initializing Static and Global Variables With the const Type Qualifier
6.14
Changing the ANSI/ISO C/C++ Language Mode
6.14.1
C99 Support (--c99)
6.14.2
C11 Support (--c11)
6.14.3
Strict ANSI Mode and Relaxed ANSI Mode (--strict_ansi and --relaxed_ansi)
6.15
GNU and Clang Language Extensions
6.15.1
Extensions
6.15.2
Function Attributes
6.15.3
For Loop Attributes
6.15.4
Variable Attributes
6.15.5
Type Attributes
6.15.6
Built-In Functions
6.15.7
Using the Byte Peripheral Type Attribute
6.16
Compiler Limits
7
Run-Time Environment
7.1
Memory Model
7.1.1
Sections
7.1.2
C/C++ System Stack
7.1.3
Allocating .econst to Program Memory
7.1.4
Dynamic Memory Allocation
7.1.5
Initialization of Variables
7.1.6
Allocating Memory for Static and Global Variables
7.1.7
Field/Structure Alignment
7.1.8
Character String Constants
7.2
Register Conventions
7.2.1
TMS320C28x Register Use and Preservation
7.2.2
Status Registers
7.3
Function Structure and Calling Conventions
7.3.1
How a Function Makes a Call
7.3.2
How a Called Function Responds
7.3.3
Special Case for a Called Function (Large Frames)
7.3.4
Accessing Arguments and Local Variables
7.3.5
Allocating the Frame and Accessing 32-Bit Values in Memory
7.4
Accessing Linker Symbols in C and C++
7.5
Interfacing C and C++ With Assembly Language
7.5.1
Using Assembly Language Modules With C/C++ Code
7.5.2
Accessing Assembly Language Functions From C/C++
7.5.2.1
Calling an Assembly Language Function From a C/C++ Program
7.5.2.2
Assembly Language Program Called by
261
7.5.3
Accessing Assembly Language Variables From C/C++
7.5.3.1
Accessing Assembly Language Global Variables
7.5.3.1.1
Assembly Language Variable Program
7.5.3.1.2
C Program to Access Assembly Language From
266
7.5.3.2
Accessing Assembly Language Constants
7.5.3.2.1
Accessing an Assembly Language Constant From C
7.5.3.2.2
Assembly Language Program for
270
7.5.4
Sharing C/C++ Header Files With Assembly Source
7.5.5
Using Inline Assembly Language
7.6
Using Intrinsics to Access Assembly Language Statements
7.6.1
Floating Point Conversion Intrinsics
7.6.2
Floating Point Unit (FPU) Intrinsics
7.6.3
Trigonometric Math Unit (TMU) Intrinsics
7.6.4
Fast Integer Division Intrinsics
7.7
Interrupt Handling
7.7.1
General Points About Interrupts
7.7.2
Using C/C++ Interrupt Routines
7.8
Integer Expression Analysis
7.8.1
Operations Evaluated With Run-Time-Support Calls
7.8.2
Division Operations with Fast Integer Division Support
7.8.3
C/C++ Code Access to the Upper 16 Bits of 16-Bit Multiply
7.9
Floating-Point Expression Analysis
7.10
System Initialization
7.10.1
Boot Hook Functions for System Pre-Initialization
7.10.2
Run-Time Stack
7.10.3
Automatic Initialization of Variables for COFF
7.10.3.1
Initialization Tables
291
7.10.3.2
Autoinitialization of Variables at Run Time for COFF
7.10.3.3
Initialization of Variables at Load Time for COFF
7.10.3.4
Global Constructors
7.10.4
Automatic Initialization of Variables for EABI
7.10.4.1
Zero Initializing Variables
7.10.4.2
Direct Initialization for EABI
7.10.4.3
Autoinitialization of Variables at Run Time for EABI
7.10.4.4
Autoinitialization Tables for EABI
7.10.4.4.1
Length Followed by Data Format
7.10.4.4.2
Zero Initialization Format
7.10.4.4.3
Run Length Encoded (RLE) Format
7.10.4.4.4
Lempel-Ziv-Storer-Szymanski Compression (LZSS) Format
7.10.4.5
Initialization of Variables at Load Time
7.10.4.6
Global Constructors
8
Using Run-Time-Support Functions and Building Libraries
8.1
C and C++ Run-Time Support Libraries
8.1.1
Linking Code With the Object Library
8.1.2
Header Files
8.1.3
Modifying a Library Function
8.1.4
Support for String Handling
8.1.5
Minimal Support for Internationalization
8.1.6
Support for Time and Clock Functions
8.1.7
Allowable Number of Open Files
8.1.8
Library Naming Conventions
8.2
The C I/O Functions
8.2.1
High-Level I/O Functions
8.2.1.1
Formatting and the Format Conversion Buffer
8.2.2
Overview of Low-Level I/O Implementation
open
close
read
write
lseek
unlink
rename
8.2.3
Device-Driver Level I/O Functions
DEV_open
DEV_close
DEV_read
DEV_write
DEV_lseek
DEV_unlink
DEV_rename
8.2.4
Adding a User-Defined Device Driver for C I/O
8.2.4.1
Mapping Default Streams to Device
8.2.5
The device Prefix
add_device
339
8.2.5.1
Program for C I/O Device
8.3
Handling Reentrancy (_register_lock() and _register_unlock() Functions)
8.4
Reinitializing Variables During a Warm Start
8.5
Library-Build Process
8.5.1
Required Non-Texas Instruments Software
8.5.2
Using the Library-Build Process
8.5.2.1
Automatic Standard Library Rebuilding by the Linker
8.5.2.2
Invoking mklib Manually
8.5.2.2.1
Building Standard Libraries
8.5.2.2.2
Shared or Read-Only Library Directory
8.5.2.2.3
Building Libraries With Custom Options
8.5.2.2.4
The mklib Program Option Summary
8.5.3
Extending mklib
8.5.3.1
Underlying Mechanism
8.5.3.2
Libraries From Other Vendors
9
C++ Name Demangler
9.1
Invoking the C++ Name Demangler
9.2
Sample Usage of the C++ Name Demangler
10
CLA Compiler
10.1
How to Invoke the CLA Compiler
10.1.1
CLA-Specific Options
10.2
CLA C Language Implementation
10.2.1
Variables and Data Types
10.2.2
Pragmas, Keywords, and Intrinsics
10.2.3
Optimizations with the CLA Compiler
10.2.4
C Language Restrictions
10.2.5
Memory Model - Sections
10.2.6
Function Structure and Calling Conventions
A Glossary
369
B Revision History
B Earlier Revisions