Tms320c28x Optimizing C/C++ Compiler V6.0 User's Guide (Rev. D)
Total Page:16
File Type:pdf, Size:1020Kb
TMS320C28x Optimizing C/C++ Compiler v6.0 User's Guide Literature Number: SPRU514D May 2011 2 SPRU514D–May 2011 Submit Documentation Feedback Copyright © 2011, Texas Instruments Incorporated Contents Preface ...................................................................................................................................... 11 1 Introduction to the Software Development Tools ................................................................... 15 1.1 Software Development Tools Overview ................................................................................ 16 1.2 C/C++ Compiler Overview ................................................................................................ 18 1.2.1 ANSI/ISO Standard ............................................................................................... 18 1.2.2 Output Files ....................................................................................................... 18 1.2.3 Compiler Interface ................................................................................................ 18 1.2.4 Utilities ............................................................................................................. 18 2 Using the C/C++ Compiler .................................................................................................. 19 2.1 About the Compiler ........................................................................................................ 20 2.2 Invoking the C/C++ Compiler ............................................................................................ 20 2.3 Changing the Compiler's Behavior With Options ...................................................................... 21 2.3.1 Frequently Used Options ........................................................................................ 29 2.3.2 Miscellaneous Useful Options .................................................................................. 31 2.3.3 Run-Time Model Options ........................................................................................ 31 2.3.4 Symbolic Debugging and Profiling Options ................................................................... 33 2.3.5 Specifying Filenames ............................................................................................ 34 2.3.6 Changing How the Compiler Interprets Filenames ........................................................... 34 2.3.7 Changing How the Compiler Processes C Files ............................................................. 35 2.3.8 Changing How the Compiler Interprets and Names Extensions ........................................... 35 2.3.9 Specifying Directories ............................................................................................ 35 2.3.10 Assembler Options .............................................................................................. 36 2.3.11 Dynamic Linking ................................................................................................. 37 2.3.12 Deprecated Options ............................................................................................. 37 2.4 Controlling the Compiler Through Environment Variables ........................................................... 38 2.4.1 Setting Default Compiler Options (C2000_C_OPTION) ..................................................... 38 2.4.2 Naming an Alternate Directory (C2000_C_DIR) .............................................................. 39 2.5 Precompiled Header Support ............................................................................................ 39 2.5.1 Automatic Precompiled Header ................................................................................. 39 2.5.2 Manual Precompiled Header .................................................................................... 40 2.5.3 Additional Precompiled Header Options ....................................................................... 40 2.6 Controlling the Preprocessor ............................................................................................. 40 2.6.1 Predefined Macro Names ....................................................................................... 40 2.6.2 The Search Path for #include Files ............................................................................ 41 2.6.3 Generating a Preprocessed Listing File (--preproc_only Option) .......................................... 42 2.6.4 Continuing Compilation After Preprocessing (--preproc_with_compile Option) .......................... 42 2.6.5 Generating a Preprocessed Listing File With Comments (--preproc_with_comment Option) .......... 42 2.6.6 Generating a Preprocessed Listing File With Line-Control Information (--preproc_with_line Option) ............................................................................................................. 42 2.6.7 Generating Preprocessed Output for a Make Utility (--preproc_dependency Option) ................... 43 2.6.8 Generating a List of Files Included With the #include Directive (--preproc_includes Option) .......... 43 2.6.9 Generating a List of Macros in a File (--preproc_macros Option) .......................................... 43 2.7 Understanding Diagnostic Messages ................................................................................... 43 2.7.1 Controlling Diagnostics .......................................................................................... 44 2.7.2 How You Can Use Diagnostic Suppression Options ........................................................ 45 SPRU514D–May 2011 Contents 3 Submit Documentation Feedback Copyright © 2011, Texas Instruments Incorporated www.ti.com 2.8 Other Messages ........................................................................................................... 46 2.9 Generating Cross-Reference Listing Information (--gen_acp_xref Option) ........................................ 46 2.10 Generating a Raw Listing File (--gen_acp_raw Option) .............................................................. 47 2.11 Using Inline Function Expansion ........................................................................................ 48 2.11.1 Inlining Intrinsic Operators ..................................................................................... 48 2.11.2 Unguarded Definition-Controlled Inlining ..................................................................... 48 2.11.3 Guarded Inlining and the _INLINE Preprocessor Symbol .................................................. 49 2.12 Using Interlist ............................................................................................................... 50 2.13 Enabling Entry Hook and Exit Hook Functions ........................................................................ 52 3 Optimizing Your Code ........................................................................................................ 53 3.1 Invoking Optimization ..................................................................................................... 54 3.2 Performing File-Level Optimization (--opt_level=3 option) ........................................................... 55 3.2.1 Controlling File-Level Optimization (--std_lib_func_def Options) ........................................... 55 3.2.2 Creating an Optimization Information File (--gen_opt_info Option) ........................................ 55 3.3 Performing Program-Level Optimization (--program_level_compile and --opt_level=3 options) ................ 56 3.3.1 Controlling Program-Level Optimization (--call_assumptions Option) ..................................... 56 3.3.2 Optimization Considerations When Mixing C/C++ and Assembly ......................................... 57 3.4 Link-Time Optimization (--opt_level=4 Option) ........................................................................ 58 3.4.1 Option Handling ................................................................................................... 58 3.4.2 Incompatible Types ............................................................................................... 59 3.5 Special Considerations When Using Optimization .................................................................... 59 3.5.1 Use Caution With asm Statements in Optimized Code ..................................................... 59 3.5.2 Use the Volatile Keyword for Necessary Memory Accesses ............................................... 59 3.6 Automatic Inline Expansion (--auto_inline Option) .................................................................... 61 3.7 Using the Interlist Feature With Optimization .......................................................................... 61 3.8 Debugging and Profiling Optimized Code .............................................................................. 64 3.8.1 Debugging Optimized Code (--symdebug:dwarf, --symdebug:coff, and --opt_level Options) .......... 64 3.8.2 Profiling Optimized Code ........................................................................................ 64 3.9 Controlling Code Size Versus Speed ................................................................................... 65 3.10 Increasing Code-Size Optimizations (--opt_for_size Option) ........................................................ 66 3.11 What Kind of Optimization Is Being Performed? ...................................................................... 68 3.11.1 Cost-Based Register Allocation ..............................................................................