Transcription of MSP430 Optimizing C/C++ Compiler v18.1.0
1 MSP430 Optimizing C/C++ Compiler User's Guide Literature Number: SLAU132R. January 2018. Contents Preface .. 9. 1 Introduction to the Software Development Tools .. 12. Software Development Tools Overview .. 13. Compiler Interface .. 15. ANSI/ISO Standard .. 15. Output Files .. 15. Utilities .. 16. 2 Using the C/C++ Compiler .. 17. About the 18. Invoking the C/C++ Compiler .. 18. Changing the Compiler 's Behavior with Options .. 19. Linker Options .. 26. Frequently Used Options .. 28. Miscellaneous Useful Options .. 29. Run-Time Model Options .. 31.
2 Symbolic Debugging Options .. 34. Specifying Filenames .. 35. Changing How the Compiler Interprets Filenames .. 35. Changing How the Compiler Processes C Files .. 35. Changing How the Compiler Interprets and Names Extensions .. 36. Specifying 36. Assembler Options .. 37. Deprecated Options .. 38. Controlling the Compiler Through Environment Variables .. 38. Setting Default Compiler Options (MSP430_C_OPTION) .. 38. Naming One or More Alternate Directories (MSP430_C_DIR).. 39. Controlling the Preprocessor .. 40. Predefined Macro Names .. 40. The Search Path for #include Files.
3 41. Support for the #warning and #warn Directives .. 42. Generating a Preprocessed Listing File (--preproc_only Option) .. 42. Continuing Compilation After Preprocessing (--preproc_with_compile Option) .. 42. Generating a Preprocessed Listing File with Comments (--preproc_with_comment Option) .. 42. Generating Preprocessed Listing with Line-Control Details (--preproc_with_line Option) .. 43. Generating Preprocessed Output for a Make Utility (--preproc_dependency Option) .. 43. Generating a List of Files Included with #include (--preproc_includes Option).
4 43. Generating a List of Macros in a File (--preproc_macros Option) .. 43. Passing Arguments to main() .. 43. Understanding Diagnostic Messages .. 44. Controlling Diagnostic Messages .. 45. How You Can Use Diagnostic Suppression Options .. 46. Other Messages .. 47. Generating Cross-Reference Listing Information (--gen_cross_reference Option) .. 47. Generating a Raw Listing File (--gen_preprocessor_listing Option) .. 47. Using Inline Function Expansion .. 49. 2 Contents SLAU132R January 2018. Submit Documentation Feedback Copyright 2018, Texas Instruments Incorporated Inlining Intrinsic Operators.
5 50. Inlining Restrictions .. 50. Using Interlist .. 51. Controlling Application Binary Interface .. 52. Enabling Entry Hook and Exit Hook Functions .. 53. 3 Optimizing Your Code .. 54. Invoking Optimization .. 55. Performing File-Level Optimization (--opt_level=3 option) .. 56. Creating an Optimization Information File (--gen_opt_info Option) .. 56. Program-Level Optimization (--program_level_compile and --opt_level=3 options) .. 56. Controlling Program-Level Optimization (--call_assumptions Option) .. 57. Optimization Considerations When Mixing C/C++ and Assembly.
6 58. Link-Time Optimization (--opt_level=4 Option) .. 59. Option Handling .. 59. Incompatible Types .. 59. Using Feedback Directed 59. Feedback Directed Optimization .. 60. Profile Data Decoder .. 62. Feedback Directed Optimization API .. 63. Feedback Directed Optimization Summary .. 63. Using Profile Information to Analyze Code Coverage .. 64. Code Coverage .. 64. Related Features and Capabilities .. 65. Accessing Aliased Variables in Optimized Code .. 66. Use Caution With asm Statements in Optimized Code .. 66. Automatic Inline Expansion (--auto_inline Option).
7 67. Using the Interlist Feature With Optimization .. 67. Debugging Optimized 69. Controlling Code Size Versus Speed .. 69. What Kind of Optimization Is Being Performed? .. 70. Cost-Based Register Allocation .. 70. Alias Disambiguation .. 70. Branch Optimizations and Control-Flow Simplification .. 71. Data Flow Optimizations .. 71. Expression Simplification .. 71. Inline Expansion of Functions .. 71. Function Symbol Aliasing .. 71. Induction Variables and Strength Reduction .. 72. Loop-Invariant Code Motion .. 72. Loop Rotation .. 72. Instruction Scheduling.
8 72. Tail Merging .. 72. Integer Division With Constant Divisor .. 72. 4 Linking C/C++ Code .. 73. Invoking the Linker Through the Compiler (-z Option) .. 74. Invoking the Linker Separately .. 74. Invoking the Linker as Part of the Compile Step .. 75. Disabling the Linker (--compile_only Compiler Option) .. 75. Linker Code Optimizations .. 76. Conditional Linking .. 76. Generating Aggregate Data Subsections (--gen_data_subsections Compiler Option) .. 76. Controlling the Linking Process .. 76. Including the Run-Time-Support Library .. 77. SLAU132R January 2018 Contents 3.
9 Submit Documentation Feedback Copyright 2018, Texas Instruments Incorporated Run-Time Initialization .. 78. Initialization by the Interrupt Vector .. 78. Initialization of the FRAM Memory Protection Unit .. 78. Initialization of Cinit and Watchdog Timer Hold .. 78. Global Object Constructors .. 79. Specifying the Type of Global Variable Initialization .. 79. Specifying Where to Allocate Sections in Memory .. 80. A Sample Linker Command File .. 81. 5 MSP430 C/C++ Language Implementation .. 82. Characteristics of MSP430 C .. 83. Implementation-Defined Behavior.
10 83. Characteristics of MSP430 C++ .. 87. Using MISRA C 2004 .. 88. Using the ULP Advisor .. 89. Advice on Hardware 89. Data Types .. 90. Size of Enum Types .. 91. Keywords .. 91. The const 92. The __interrupt Keyword .. 92. The restrict Keyword .. 93. The volatile Keyword .. 94. C++ Exception 95. Register Variables and Parameters .. 95. The __asm Statement .. 96. Pragma Directives .. 97. The BIS_IE1_INTERRUPT .. 98. The CALLS Pragma .. 98. The CHECK_MISRA Pragma .. 99. The CHECK_ULP Pragma .. 99. The CLINK Pragma .. 99. The CODE_SECTION Pragma.
