没有合适的资源?快使用搜索试试~ 我知道了~
首页tms320c6000-optimizing_compiler_users_guide_v7.4.pdf
tms320c6000-optimizing_compiler_users_guide_v7.4.pdf
需积分: 25 304 浏览量
更新于2023-05-26
评论
收藏 1.29MB PDF 举报
tms320c6000 optimizing_compiler_users'Guid_v7.4.pdf
资源详情
资源评论
资源推荐

TMS320C6000 Optimizing Compiler v7.4
User's Guide
Literature Number: SPRU187U
July 2012

Contents
Preface ...................................................................................................................................... 11
1 Introduction to the Software Development Tools ................................................................... 14
1.1 Software Development Tools Overview ................................................................................ 15
1.2 C/C++ Compiler Overview ................................................................................................ 16
1.2.1 ANSI/ISO Standard ............................................................................................... 16
1.2.2 Output Files ....................................................................................................... 17
1.2.3 Compiler Interface ................................................................................................ 17
1.2.4 Utilities ............................................................................................................. 17
2 Using the C/C++ Compiler .................................................................................................. 18
2.1 About the Compiler ........................................................................................................ 19
2.2 Invoking the C/C++ Compiler ............................................................................................ 19
2.3 Changing the Compiler's Behavior With Options ...................................................................... 20
2.3.1 Frequently Used Options ........................................................................................ 30
2.3.2 Miscellaneous Useful Options .................................................................................. 31
2.3.3 Run-Time Model Options ........................................................................................ 32
2.3.4 Selecting Target CPU Version (--silicon_version Option) ................................................... 33
2.3.5 Symbolic Debugging and Profiling Options ................................................................... 34
2.3.6 Specifying Filenames ............................................................................................ 35
2.3.7 Changing How the Compiler Interprets Filenames ........................................................... 35
2.3.8 Changing How the Compiler Processes C Files ............................................................. 36
2.3.9 Changing How the Compiler Interprets and Names Extensions ........................................... 36
2.3.10 Specifying Directories ........................................................................................... 36
2.3.11 Assembler Options .............................................................................................. 37
2.3.12 Dynamic Linking ................................................................................................. 38
2.3.13 Deprecated Options ............................................................................................. 39
2.4 Controlling the Compiler Through Environment Variables ........................................................... 39
2.4.1 Setting Default Compiler Options (C6X_C_OPTION) ....................................................... 39
2.4.2 Naming an Alternate Directory (C6X_C_DIR) ................................................................ 40
2.5 Precompiled Header Support ............................................................................................ 41
2.5.1 Automatic Precompiled Header ................................................................................. 41
2.5.2 Manual Precompiled Header .................................................................................... 41
2.5.3 Additional Precompiled Header Options ....................................................................... 41
2.6 Controlling the Preprocessor ............................................................................................. 42
2.6.1 Predefined Macro Names ....................................................................................... 42
2.6.2 The Search Path for #include Files ............................................................................ 43
2.6.3 Generating a Preprocessed Listing File (--preproc_only Option) .......................................... 44
2.6.4 Continuing Compilation After Preprocessing (--preproc_with_compile Option) .......................... 44
2.6.5 Generating a Preprocessed Listing File With Comments (--preproc_with_comment Option) .......... 44
2.6.6 Generating a Preprocessed Listing File With Line-Control Information (--preproc_with_line
Option) ............................................................................................................. 44
2.6.7 Generating Preprocessed Output for a Make Utility (--preproc_dependency Option) ................... 45
2.6.8 Generating a List of Files Included With the #include Directive (--preproc_includes Option) .......... 45
2.6.9 Generating a List of Macros in a File (--preproc_macros Option) .......................................... 45
2.7 Understanding Diagnostic Messages ................................................................................... 45
2.7.1 Controlling Diagnostics .......................................................................................... 46
2
Contents SPRU187U–July 2012
Submit Documentation Feedback
Copyright © 2012, Texas Instruments Incorporated

www.ti.com
2.7.2 How You Can Use Diagnostic Suppression Options ........................................................ 47
2.8 Other Messages ........................................................................................................... 48
2.9 Generating Cross-Reference Listing Information (--gen_acp_xref Option) ........................................ 48
2.10 Generating a Raw Listing File (--gen_acp_raw Option) .............................................................. 48
2.11 Using Inline Function Expansion ........................................................................................ 50
2.11.1 Inlining Intrinsic Operators ..................................................................................... 50
2.11.2 Automatic Inlining ................................................................................................ 50
2.11.3 Unguarded Definition-Controlled Inlining ..................................................................... 50
2.11.4 Guarded Inlining and the _INLINE Preprocessor Symbol .................................................. 51
2.11.5 Inlining Restrictions ............................................................................................. 52
2.12 Interrupt Flexibility Options (--interrupt_threshold Option) ........................................................... 53
2.13 Linking C6400 Code With C6200/C6700/Older C6400 Object Code ............................................... 54
2.14 Using Interlist ............................................................................................................... 54
2.15 Generating and Using Performance Advice ........................................................................... 55
2.16 Controlling Application Binary Interface ................................................................................ 55
2.17 Enabling Entry Hook and Exit Hook Functions ........................................................................ 57
3 Optimizing Your Code ........................................................................................................ 58
3.1 Invoking Optimization ..................................................................................................... 59
3.2 Optimizing Software Pipelining .......................................................................................... 60
3.2.1 Turn Off Software Pipelining (--disable_software_pipelining Option) ...................................... 61
3.2.2 Software Pipelining Information ................................................................................. 61
3.2.3 Collapsing Prologs and Epilogs for Improved Performance and Code Size .............................. 65
3.3 Redundant Loops .......................................................................................................... 67
3.4 Utilizing the Loop Buffer Using SPLOOP on C6400+, C6740, and C6600 ........................................ 68
3.5 Reducing Code Size (--opt_for_space (or -ms) Option) .............................................................. 68
3.6 Performing File-Level Optimization (--opt_level=3 option) ........................................................... 70
3.6.1 Controlling File-Level Optimization (--std_lib_func_def Options) ........................................... 70
3.6.2 Creating an Optimization Information File (--gen_opt_info Option) ........................................ 70
3.7 Performing Program-Level Optimization (--program_level_compile and --opt_level=3 options) ................ 71
3.7.1 Controlling Program-Level Optimization (--call_assumptions Option) ..................................... 71
3.7.2 Optimization Considerations When Mixing C/C++ and Assembly ......................................... 72
3.8 Using Feedback Directed Optimization ................................................................................. 73
3.8.1 Feedback Directed Optimization ............................................................................... 73
3.8.2 Profile Data Decoder ............................................................................................. 75
3.8.3 Feedback Directed Optimization API .......................................................................... 76
3.8.4 Feedback Directed Optimization Summary ................................................................... 76
3.9 Using Profile Information to Get Better Program Cache Layout and Analyze Code Coverage ................. 77
3.9.1 Background and Motivation ..................................................................................... 77
3.9.2 Code Coverage ................................................................................................... 78
3.9.3 What Performance Improvements Can You Expect to See? ............................................... 79
3.9.4 Program Cache Layout Related Features and Capabilities ................................................ 79
3.9.5 Program Instruction Cache Layout Development Flow ...................................................... 80
3.9.6 Comma-Separated Values (CSV) Files with Weighted Call Graph (WCG) Information ................ 83
3.9.7 Linker Command File Operator - unordered() ................................................................ 83
3.9.8 Things To Be Aware Of .......................................................................................... 86
3.10 Indicating Whether Certain Aliasing Techniques Are Used .......................................................... 87
3.10.1 Use the --aliased_variables Option When Certain Aliases are Used ..................................... 87
3.10.2 Use the --no_bad_aliases Option to Indicate That These Techniques Are Not Used .................. 87
3.10.3 Using the --no_bad_aliases Option With the Assembly Optimizer ........................................ 88
3.11 Prevent Reordering of Associative Floating-Point Operations ....................................................... 88
3.12 Use Caution With asm Statements in Optimized Code .............................................................. 89
3.13 Automatic Inline Expansion (--auto_inline Option) .................................................................... 89
3.14 Using Performance Advice to Optimize your Code ................................................................... 90
3
SPRU187U–July 2012 Contents
Submit Documentation Feedback
Copyright © 2012, Texas Instruments Incorporated

www.ti.com
3.14.1 Types of Advice .................................................................................................. 91
3.14.2 Using the Interlist Feature With Optimization ................................................................ 96
3.14.3 Debugging and Profiling Optimized Code .................................................................... 99
3.14.4 Controlling Code Size Versus Speed ....................................................................... 100
3.14.5 What Kind of Optimization Is Being Performed? .......................................................... 101
4 Using the Assembly Optimizer .......................................................................................... 104
4.1 Code Development Flow to Increase Performance ................................................................. 105
4.2 About the Assembly Optimizer ......................................................................................... 106
4.3 What You Need to Know to Write Linear Assembly ................................................................. 107
4.3.1 Linear Assembly Source Statement Format ................................................................. 108
4.3.2 Register Specification for Linear Assembly .................................................................. 109
4.3.3 Functional Unit Specification for Linear Assembly .......................................................... 111
4.3.4 Using Linear Assembly Source Comments .................................................................. 111
4.3.5 Assembly File Retains Your Symbolic Register Names ................................................... 112
4.4 Assembly Optimizer Directives ......................................................................................... 113
4.4.1 Instructions That Are Not Allowed in Procedures ........................................................... 126
4.5 Avoiding Memory Bank Conflicts With the Assembly Optimizer ................................................... 127
4.5.1 Preventing Memory Bank Conflicts ........................................................................... 128
4.5.2 A Dot Product Example That Avoids Memory Bank Conflicts ............................................ 129
4.5.3 Memory Bank Conflicts for Indexed Pointers ................................................................ 132
4.5.4 Memory Bank Conflict Algorithm .............................................................................. 133
4.6 Memory Alias Disambiguation .......................................................................................... 133
4.6.1 How the Assembly Optimizer Handles Memory References (Default) ................................... 133
4.6.2 Using the --no_bad_aliases Option to Handle Memory References ..................................... 133
4.6.3 Using the .no_mdep Directive ................................................................................. 133
4.6.4 Using the .mdep Directive to Identify Specific Memory Dependencies .................................. 134
4.6.5 Memory Alias Examples ....................................................................................... 135
5 Linking C/C++ Code ......................................................................................................... 137
5.1 Invoking the Linker Through the Compiler (-z Option) .............................................................. 138
5.1.1 Invoking the Linker Separately ................................................................................ 138
5.1.2 Invoking the Linker as Part of the Compile Step ............................................................ 139
5.1.3 Disabling the Linker (--compile_only Compiler Option) .................................................... 139
5.2 Linker Code Optimizations .............................................................................................. 140
5.2.1 Generating Function Subsections (--gen_func_subsections Compiler Option) ......................... 140
5.2.2 Conditional Linking .............................................................................................. 140
5.3 Controlling the Linking Process ........................................................................................ 141
5.3.1 Including the Run-Time-Support Library ..................................................................... 141
5.3.2 Run-Time Initialization .......................................................................................... 142
5.3.3 Global Object Constructors .................................................................................... 142
5.3.4 Specifying the Type of Global Variable Initialization ....................................................... 143
5.3.5 Specifying Where to Allocate Sections in Memory ......................................................... 143
5.3.6 A Sample Linker Command File .............................................................................. 145
6 TMS320C6000C/C++ Language Implementation ................................................................... 146
6.1 Characteristics of TMS320C6000 C ................................................................................... 147
6.2 Characteristics of TMS320C6000 C++ ................................................................................ 147
6.3 Using MISRA-C:2004 .................................................................................................... 148
6.4 Data Types ................................................................................................................ 149
6.5 Keywords .................................................................................................................. 150
6.5.1 The const Keyword ............................................................................................. 150
6.5.2 The cregister Keyword ......................................................................................... 150
6.5.3 The interrupt Keyword .......................................................................................... 152
6.5.4 The near and far Keywords .................................................................................... 152
6.5.5 The restrict Keyword ............................................................................................ 153
4
Contents SPRU187U–July 2012
Submit Documentation Feedback
Copyright © 2012, Texas Instruments Incorporated

www.ti.com
6.5.6 The volatile Keyword ........................................................................................... 154
6.6 C++ Exception Handling ................................................................................................ 155
6.7 Register Variables and Parameters ................................................................................... 155
6.8 The asm Statement ...................................................................................................... 156
6.9 Pragma Directives ....................................................................................................... 157
6.9.1 The CHECK_MISRA Pragma ................................................................................. 158
6.9.2 The CLINK Pragma ............................................................................................. 158
6.9.3 The CODE_SECTION Pragma ............................................................................... 158
6.9.4 The DATA_ALIGN Pragma .................................................................................... 159
6.9.5 The DATA_MEM_BANK Pragma ............................................................................. 160
6.9.6 The DATA_SECTION Pragma ................................................................................ 161
6.9.7 The Diagnostic Message Pragmas ........................................................................... 162
6.9.8 The FUNC_ALWAYS_INLINE Pragma ...................................................................... 162
6.9.9 The FUNC_CANNOT_INLINE Pragma ...................................................................... 163
6.9.10 The FUNC_EXT_CALLED Pragma ......................................................................... 163
6.9.11 The FUNC_INTERRUPT_THRESHOLD Pragma ......................................................... 164
6.9.12 The FUNC_IS_PURE Pragma ............................................................................... 164
6.9.13 The FUNC_IS_SYSTEM Pragma ............................................................................ 165
6.9.14 The FUNC_NEVER_RETURNS Pragma ................................................................... 165
6.9.15 The FUNC_NO_GLOBAL_ASG Pragma ................................................................... 165
6.9.16 The FUNC_NO_IND_ASG Pragma ......................................................................... 166
6.9.17 The FUNCTION_OPTIONS Pragma ........................................................................ 166
6.9.18 The INTERRUPT Pragma .................................................................................... 166
6.9.19 The LOCATION Pragma ...................................................................................... 167
6.9.20 The MUST_ITERATE Pragma ............................................................................... 167
6.9.21 The NMI_INTERRUPT Pragma .............................................................................. 168
6.9.22 The NOINIT and PERSISTENT Pragmas .................................................................. 169
6.9.23 The NO_HOOKS Pragma .................................................................................... 169
6.9.24 The PROB_ITERATE Pragma ............................................................................... 170
6.9.25 The RESET_MISRA Pragma ................................................................................. 170
6.9.26 The RETAIN Pragma .......................................................................................... 170
6.9.27 The SET_CODE_SECTION and SET_DATA_SECTION Pragmas ..................................... 171
6.9.28 The STRUCT_ALIGN Pragma ............................................................................... 172
6.9.29 The UNROLL Pragma ......................................................................................... 172
6.10 The _Pragma Operator .................................................................................................. 173
6.11 Application Binary Interface ............................................................................................ 174
6.11.1 COFF ABI ....................................................................................................... 174
6.11.2 EABI ............................................................................................................. 174
6.12 Object File Symbol Naming Conventions (Linknames) ............................................................. 174
6.13 Initializing Static and Global Variables in COFF ABI Mode ........................................................ 175
6.13.1 Initializing Static and Global Variables With the Linker ................................................... 175
6.13.2 Initializing Static and Global Variables With the const Type Qualifier .................................. 175
6.14 Changing the ANSI/ISO C Language Mode .......................................................................... 176
6.14.1 Compatibility With K&R C (--kr_compatible Option) ....................................................... 176
6.14.2 Enabling Strict ANSI/ISO Mode and Relaxed ANSI/ISO Mode (--strict_ansi and --relaxed_ansi
Options) .......................................................................................................... 177
6.14.3 Enabling Embedded C++ Mode (--embedded_cpp Option) .............................................. 178
6.15 GNU Language Extensions ............................................................................................. 178
6.15.1 Extensions ...................................................................................................... 178
6.15.2 Function Attributes ............................................................................................. 179
6.15.3 Variable Attributes ............................................................................................. 180
6.15.4 Type Attributes ................................................................................................. 180
6.15.5 Built-In Functions .............................................................................................. 181
5
SPRU187U–July 2012 Contents
Submit Documentation Feedback
Copyright © 2012, Texas Instruments Incorporated
剩余277页未读,继续阅读













安全验证
文档复制为VIP权益,开通VIP直接复制

评论0