ARM Optimizing C/C++ Compiler V20.2.0.LTS User's Guide (Rev. V)
Total Page:16
File Type:pdf, Size:1020Kb
ARM Optimizing C/C++ Compiler v20.2.0.LTS User's Guide Literature Number: SPNU151V January 1998–Revised February 2020 Contents Preface ........................................................................................................................................ 9 1 Introduction to the Software Development Tools.................................................................... 12 1.1 Software Development Tools Overview ................................................................................. 13 1.2 Compiler Interface.......................................................................................................... 15 1.3 ANSI/ISO Standard ........................................................................................................ 15 1.4 Output Files ................................................................................................................. 15 1.5 Utilities ....................................................................................................................... 16 2 Using the C/C++ Compiler ................................................................................................... 17 2.1 About the Compiler......................................................................................................... 18 2.2 Invoking the C/C++ Compiler ............................................................................................. 18 2.3 Changing the Compiler's Behavior with Options ....................................................................... 19 2.3.1 Linker Options ..................................................................................................... 25 2.3.2 Frequently Used Options......................................................................................... 27 2.3.3 Miscellaneous Useful Options ................................................................................... 28 2.3.4 Run-Time Model Options......................................................................................... 30 2.3.5 Symbolic Debugging and Profiling Options .................................................................... 32 2.3.6 Specifying Filenames ............................................................................................. 33 2.3.7 Changing How the Compiler Interprets Filenames ........................................................... 33 2.3.8 Changing How the Compiler Processes C Files .............................................................. 34 2.3.9 Changing How the Compiler Interprets and Names Extensions ............................................ 34 2.3.10 Specifying Directories............................................................................................ 34 2.3.11 Assembler Options............................................................................................... 35 2.3.12 Deprecated Options.............................................................................................. 35 2.4 Controlling the Compiler Through Environment Variables............................................................ 35 2.4.1 Setting Default Compiler Options (TI_ARM_C_OPTION).................................................... 36 2.4.2 Naming One or More Alternate Directories (TI_ARM_C_DIR) .............................................. 37 2.5 Controlling the Preprocessor ............................................................................................. 38 2.5.1 Predefined Macro Names ........................................................................................ 38 2.5.2 The Search Path for #include Files ............................................................................. 41 2.5.3 Support for the #warning and #warn Directives ............................................................... 42 2.5.4 Generating a Preprocessed Listing File (--preproc_only Option) ........................................... 43 2.5.5 Continuing Compilation After Preprocessing (--preproc_with_compile Option) ........................... 43 2.5.6 Generating a Preprocessed Listing File with Comments (--preproc_with_comment Option) ........... 43 2.5.7 Generating Preprocessed Listing with Line-Control Details (--preproc_with_line Option) ............... 43 2.5.8 Generating Preprocessed Output for a Make Utility (--preproc_dependency Option) ................... 43 2.5.9 Generating a List of Files Included with #include (--preproc_includes Option) ........................... 43 2.5.10 Generating a List of Macros in a File (--preproc_macros Option) ......................................... 43 2.6 Passing Arguments to main()............................................................................................. 44 2.7 Understanding Diagnostic Messages.................................................................................... 44 2.7.1 Controlling Diagnostic Messages ............................................................................... 46 2.7.2 How You Can Use Diagnostic Suppression Options ......................................................... 47 2.8 Other Messages ............................................................................................................ 47 2.9 Generating Cross-Reference Listing Information (--gen_cross_reference Option)................................ 47 2.10 Generating a Raw Listing File (--gen_preprocessor_listing Option)................................................. 48 2.11 Using Inline Function Expansion ......................................................................................... 49 2 Contents SPNU151V–January 1998–Revised February 2020 Submit Documentation Feedback Copyright © 1998–2020, Texas Instruments Incorporated www.ti.com 2.11.1 Inlining Intrinsic Operators ...................................................................................... 50 2.11.2 Inlining Restrictions .............................................................................................. 51 2.12 Using Interlist ............................................................................................................... 52 2.13 Controlling Application Binary Interface ................................................................................. 53 2.14 VFP Support ................................................................................................................ 54 2.15 Enabling Entry Hook and Exit Hook Functions......................................................................... 55 3 Optimizing Your Code......................................................................................................... 56 3.1 Invoking Optimization ...................................................................................................... 57 3.2 Controlling Code Size Versus Speed ................................................................................... 58 3.3 Performing File-Level Optimization (--opt_level=3 option)............................................................ 58 3.3.1 Creating an Optimization Information File (--gen_opt_info Option)......................................... 58 3.4 Program-Level Optimization (--program_level_compile and --opt_level=3 options)............................... 59 3.4.1 Controlling Program-Level Optimization (--call_assumptions Option)...................................... 59 3.4.2 Optimization Considerations When Mixing C/C++ and Assembly .......................................... 60 3.5 Automatic Inline Expansion (--auto_inline Option) ..................................................................... 61 3.6 Link-Time Optimization (--opt_level=4 Option) ......................................................................... 62 3.6.1 Option Handling ................................................................................................... 62 3.6.2 Incompatible Types ............................................................................................... 62 3.7 Using Feedback Directed Optimization.................................................................................. 63 3.7.1 Feedback Directed Optimization ................................................................................ 63 3.7.2 Profile Data Decoder.............................................................................................. 65 3.7.3 Feedback Directed Optimization API ........................................................................... 66 3.7.4 Feedback Directed Optimization Summary .................................................................... 66 3.8 Using Profile Information to Analyze Code Coverage ................................................................. 67 3.8.1 Code Coverage.................................................................................................... 67 3.8.2 Related Features and Capabilities .............................................................................. 68 3.9 Accessing Aliased Variables in Optimized Code....................................................................... 69 3.10 Use Caution With asm Statements in Optimized Code ............................................................... 69 3.11 Using the Interlist Feature With Optimization........................................................................... 69 3.12 Debugging and Profiling Optimized Code............................................................................... 71 3.12.1 Profiling Optimized Code.......................................................................................