www.ti.com
2.9 Generating Cross-Reference Listing Information (--gen_acp_xref Option) ........................................ 41
2.10 Generating a Raw Listing File (--gen_acp_raw Option) .............................................................. 41
2.11 Using Inline Function Expansion ........................................................................................ 43
2.11.1 Inlining Intrinsic Operators ..................................................................................... 43
2.11.2 Using the inline Keyword, the --no_inlining Option, and Level 3 Optimization .......................... 43
2.12 Using Interlist ............................................................................................................... 44
2.13 Controlling Application Binary Interface ................................................................................ 45
2.14 Enabling Entry Hook and Exit Hook Functions ........................................................................ 46
3 Optimizing Your Code ........................................................................................................ 47
3.1 Invoking Optimization ..................................................................................................... 48
3.2 Performing File-Level Optimization (--opt_level=3 option) ........................................................... 49
3.2.1 Controlling File-Level Optimization (--std_lib_func_def Options) ........................................... 49
3.2.2 Creating an Optimization Information File (--gen_opt_info Option) ........................................ 49
3.3 Performing Program-Level Optimization (--program_level_compile and --opt_level=3 options) ................ 50
3.3.1 Controlling Program-Level Optimization (--call_assumptions Option) ..................................... 50
3.3.2 Optimization Considerations When Mixing C/C++ and Assembly ......................................... 51
3.4 Link-Time Optimization (--opt_level=4 Option) ........................................................................ 52
3.4.1 Option Handling ................................................................................................... 52
3.4.2 Incompatible Types ............................................................................................... 53
3.5 Accessing Aliased Variables in Optimized Code ...................................................................... 53
3.6 Use Caution With asm Statements in Optimized Code .............................................................. 53
3.7 Automatic Inline Expansion (--auto_inline Option) .................................................................... 54
4 Linking C/C++ Code ........................................................................................................... 55
4.1 Invoking the Linker Through the Compiler (-z Option) ................................................................ 56
4.1.1 Invoking the Linker Separately ................................................................................. 56
4.1.2 Invoking the Linker as Part of the Compile Step ............................................................. 57
4.1.3 Disabling the Linker (--compile_only Compiler Option) ...................................................... 57
4.2 Linker Code Optimizations ............................................................................................... 58
4.2.1 Generating Function Subsections (--gen_func_subsections Compiler Option) .......................... 58
4.2.2 Conditional Linking ............................................................................................... 58
4.3 Controlling the Linking Process .......................................................................................... 59
4.3.1 Including the Run-Time-Support Library ....................................................................... 59
4.3.2 Run-Time Initialization ........................................................................................... 60
4.3.3 Initialization by the Interrupt Vector ............................................................................ 60
4.3.4 Initialization of the FRAM Memory Protection Unit ........................................................... 60
4.3.5 Global Object Constructors ..................................................................................... 60
4.3.6 Specifying the Type of Global Variable Initialization ......................................................... 61
4.3.7 Specifying Where to Allocate Sections in Memory ........................................................... 62
4.3.8 A Sample Linker Command File ................................................................................ 63
5 MSP430 C/C++ Language Implementation ............................................................................ 64
5.1 Characteristics of MSP430 C ............................................................................................ 65
5.2 Characteristics of MSP430 C++ ......................................................................................... 65
5.3 Using MISRA-C:2004 ..................................................................................................... 66
5.4 Using the ULP Advisor .................................................................................................... 66
5.5 Data Types ................................................................................................................. 67
5.6 Keywords ................................................................................................................... 69
5.6.1 The const Keyword ............................................................................................... 69
5.6.2 The interrupt Keyword ........................................................................................... 69
5.6.3 The restrict Keyword ............................................................................................. 70
5.6.4 The volatile Keyword ............................................................................................. 71
5.7 C++ Exception Handling .................................................................................................. 72
5.8 Register Variables and Parameters ..................................................................................... 72
5.9 The asm Statement ....................................................................................................... 73
3
SLAU132G–May 2012 Contents
Submit Documentation Feedback
Copyright © 2012, Texas Instruments Incorporated