| The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers. |
Literature Number: SPRU187G March 2000 Copyright 2000, Texas Inst
Top Searches for this datasheetTMS320C6000 Optimizing Compiler User's Guide Literature Number: SPRU187G March 2000 Copyright 2000, Texas Instruments Incorporated Preface Read This First About This Manual TMS320C6000 Optimizing C/C++ Compiler User's Guide explains these compiler tools: Compiler Assembly optimizer Standalone simulator Library-build utility name demangling utility TMS320C6000 C/C++ compiler accepts well American National Standards Institute (ANSI) standard source code produces assembly language source code TMS320C6000 device. This user's guide discusses characteristics C/C++ compiler. assumes that already know write C/C++ programs. Programming Language (second edition), Brian Kernighan Dennis Ritchie, describes based ANSI standard. Kernighan Ritchie (hereafter referred K&R) book supplement this manual. References opposed ANSI this manual refer language defined first edition Kernighan Ritchie's Programming Language. Before information about C/C++ compiler this user's guide, should install C/C++ compiler tools. Contents Notational Conventions Notational Conventions This document uses following conventions: Program listings, program examples, interactive displays shown special typeface. Examples bold version special typeface emphasis; interactive displays bold version special typeface distinguish commands that enter from items that system displays (such prompts, command output, error messages, etc.). Here sample code: #include <stdio.h> main() printf("hello, world\n"); syntax descriptions, instruction, command, directive bold- face typeface parameters italics. Portions syntax that bold must entered shown; portions syntax that italics describe type information that should entered. Syntax that entered command line centered bounded box: cl6x [options] [filenames] [link_options] [object files]] Syntax used text file left justified bounded box: inline return-type function-name (parameter declarations) {function} Square brackets identify optional parameter. optional parameter, specify information within brackets; enter brackets themselves. This example command that optional parameter: load6x [options] filename.out load6x command parameters. first parameter, options, optional. second parameter, filename.out, required. Braces indicate that must choose parameters within braces; enter braces themselves. This example command with braces that included actual syntax indicate that must specify either option: lnk6x -cr} filenames name.out] libraryname Notational Conventions Related Documentation From Texas Instruments TMS320C6200 core referred 'C6200. TMS320C6400 core referred '6400. TMS320C6700 core referred '6700. TMS320C6000 'C6000 refer either 'C6200, '6400 'C6700. Related Documentation From Texas Instruments following books describe TMS320C6000 related support tools. obtain these documents, call Texas Instruments Literature Response Center (800) 477-8924. When ordering, identify book title literature number (located title page): TMS320C6000 Assembly Language Tools User's Guide (literature number SPRU186) describes assembly language tools (assembler, linker, other tools used develop assembly language code), assembler directives, macros, common object file format, symbolic debugging directives 'C6000 generation devices. Code Composer User's Guide (literature number SPRU296) explains Code Composer development environment build debug embedded real-time applications. TMS320C6000 Programmer's Guide (literature number SPRU198) describes ways optimize assembly code TMS320C6000 DSPs includes application program examples. TMS320C6000 Instruction Reference Guide (literature number SPRU189) describes 'C6000 architecture, instruction set, pipeline, interrupts these digital signal processors. TMS320C6000 Peripherals Reference Guide (literature number SPRU190) describes common peripherals available TMS320C6000 digital signal processors. This book includes information internal data program memories, external memory interface (EMIF), host port interface (HPI), multichannel buffered serial ports (McBSPs), direct memory access (DMA), enhanced (EDMA), expansion bus, clocking phase-locked loop (PLL), power-down modes. TMS320C6000 Technical Brief (literature number SPRU197) gives introduction 'C6000 platform digital signal processors, development tools, third-party support. Read This First Related Documentation Trademarks Related Documentation Related Documentation following books supplement this user's guide: American National Standard Information Systems-Programming Language X3.159-1989, American National Standards Institute (ANSI standard Working Paper Draft Proposed International Standard Information Systems-Programming Language X3J16/WG21, American National Standards Institute Reference Manual (fourth edition), Samuel Harbison, Steele Jr., published Prentice Hall, Englewood Cliffs, Jersey Programming Steve Kochan, Hayden Book Company Programming Language (second edition), Brian Kernighan Dennis Ritchie, published Prentice-Hall, Englewood Cliffs, Jersey, 1988 Annotated Reference Manual, Margaret Ellis Bjame Stroustrup, published Addison-Wesley Publishing Company, Reading, Massachusetts, 1990 Programming Language (second edition), Bjame Stroustrup, published Addison-Wesley Publishing Company, Reading, Massachusetts, 1990 Trademarks Solaris SunOS trademarks Microsystems, Inc. UNIX registered trademark United States other countries, licensed exclusively through X/Open Company Limited. Windows Windows registered trademarks Microsoft Corporation. Hotline On-line trademark Texas Instruments Incorporated. Contents Contents Introduction Provides overview TMS320C6000 software development tools, specifically optimizing compiler. Software Development Tools Overview C/C++ Compiler Overview 1.2.1 C/C++ Language Features 1.2.2 Output Files 1.2.3 Compiler Interface 1.2.4 Compiler Operation 1.2.5 Utilities Using C/C++ Compiler Describes operate C/C++ compiler shell program. Contains instructions invoking shell program, which compiles, assembles, links C/C++ source file. Discusses interlist utility, options, compiler errors. About Shell Program Invoking C/C++ Compiler Shell Changing Compiler's Behavior With Options 2.3.1 Frequently Used Options 2-15 2.3.2 Specifying Filenames 2-18 2.3.3 Changing Shell Program Interprets Filenames (-fa, -fc, -fg, -fl, -fo, Options) 2-19 2.3.4 Changing Shell Program Interprets Names Extensions (-ea, -el, Options) 2-20 2.3.5 Specifying Directories (-fb, -ff, -fr, -fs, Options) 2-21 2.3.6 Options That Control Assembler 2-22 Setting Default Shell Options (C_OPTION C_C6X_OPTION) 2-23 Controlling Preprocessor 2-24 2.5.1 Predefined Macro Names 2-24 2.5.2 Search Path #include Files 2-25 2.5.3 Generating Preprocessed Listing File (-ppo Option) 2-27 2.5.4 Continuing Compilation After Preprocessing (-ppa Option) 2-27 2.5.5 Generating Preprocessed Listing File With Comments (-ppc Option) 2-28 2.5.6 Generating Preprocessed Listing File With Line-Control Information (-ppl Option) 2-28 2.5.7 Generating Preprocessed Output Make Utility (-ppd Option) 2-28 2.5.8 Generating List Files Included With #include Directive (-ppi Option) 2-28 Contents 2.10 2.11 2.12 Understanding Diagnostic Messages 2.6.1 Controlling Diagnostics 2.6.2 Diagnostic Suppression Options Other Messages Generating Cross-Reference Listing Information (-px Option) Generating Listing File (-pl Option) Using Inline Function Expansion 2.10.1 Inlining Intrinsic Operators 2.10.2 Automatic Inlining 2.10.3 Unguarded Definition-Controlled Inlining 2.10.4 Guarded Inlining _INLINE Preprocessor Symbol 2.10.5 Inlining Restrictions Interrupt Flexibility Options (-mi Option) Using Interlist Utility 2-29 2-31 2-32 2-33 2-33 2-34 2-36 2-36 2-36 2-37 2-38 2-40 2-41 2-42 Optimizing Your Code Describes optimize your code, including such features software pipelining loop unrolling. Also describes types optimizations that performed when optimizer. Invoking Optimization Optimizing Software Pipelining 3.2.1 Turn Software Pipelining (-mu Option) 3.2.2 Software Pipelining Information 3.2.3 Collapsing Prologs Epilogs Improved Performance Code Size 3-13 3.2.4 Selecting Target Version (-mv Option) 3-15 Redundant Loops 3-16 Reducing Code Size (-ms Option) 3-17 Performing File-Level Optimization Option) 3-18 3.5.1 Controlling File-Level Optimization (-oln Option) 3-18 3.5.2 Creating Optimization Information File (-onn Option) 3-19 Performing Program-Level Optimization (-pm Options) 3-20 3.6.1 Controlling Program-Level Optimization (-opn Option) 3-20 3.6.2 Optimization Considerations When Mixing C/C++ Assembly 3-22 Indicating Whether Certain Aliasing Techniques Used 3-24 3.7.1 Option When Certain Aliases Used 3-24 3.7.2 Option Indicate That These Techniques Used 3-25 3.7.3 Using Option With Assembly Optimizer 3-26 Prevent Reordering Associative Floating-Point Operations 3-27 Caution With Statements Optimized Code 3-27 Automatic Inline Expansion (-oi Option) 3-28 Using Interlist Utility With Optimizer 3-29 3.10 3.11 viii Contents 3.12 3.13 Debugging Profiling Optimized Code 3.12.1 Debugging Optimized Code Options) 3.12.2 Profiling Optimized Code (-mg Options) What Kind Optimization Being Performed? 3.13.1 Cost-Based Register Allocation 3.13.2 Alias Disambiguation 3.13.3 Branch Optimizations Control-Flow Simplification 3.13.4 Data Flow Optimizations 3.13.5 Expression Simplification 3.13.6 Inline Expansion Functions 3.13.7 Induction Variables Strength Reduction 3.13.8 Loop-Invariant Code Motion 3.13.9 Loop Rotation 3.13.10 Register Variables 3.13.11 Register Tracking/Targeting 3.13.12 Software Pipelining 3-32 3-32 3-33 3-34 3-35 3-37 3-37 3-40 3-40 3-41 3-42 3-43 3-43 3-43 3-43 3-44 Using Assembly Optimizer Describes assembly optimizer, which schedules instructions allocates registers you. Also describes write code assembly optimizer, including information about directives that should with assembly optimizer. Code Development Flow Increase Performance About Assembly Optimizer What Need Know Write Linear Assembly 4.3.1 Linear Assembly Source Statement Format 4.3.2 Functional Unit Specification Linear Assembly 4.3.3 Using Linear Assembly Source Comments 4-14 Assembly Optimizer Directives 4-16 Avoiding Memory Bank Conflicts With Assembly Optimizer 4-34 4.5.1 Preventing Memory Bank Conflicts 4-35 4.5.2 Product Example That Avoids Memory Bank Conflicts 4-38 4.5.3 Memory Bank Conflicts Indexed Pointers 4-42 4.5.4 Memory Bank Conflict Algorithm 4-43 Memory Alias Disambiguation 4-44 4.6.1 Assembly Optimizer Handles Memory References (Default) 4-44 4.6.2 Using Option Handle Memory References 4-44 4.6.3 Using .no_mdep Directive 4-44 4.6.4 Using .mdep Directive Identify Specific Memory Dependences 4-45 4.6.5 Memory Alias Examples 4-47 Contents Contents Linking C/C++ Code Describes link using stand-alone program with compiler shell meet special requirements linking code. Invoking Linker Individual Program Invoking Linker With Compiler Shell Option) Disabling Linker Shell Option) Linker Options Controlling Linking Process 5.5.1 Linking With Run-Time-Support Libraries 5.5.2 Run-Time Initialization 5.5.3 Global Variable Construction 5-10 5.5.4 Specifying Type Initialization 5-10 5.5.5 Specifying Where Allocate Sections Memory 5-11 5.5.6 Sample Linker Command File 5-13 Using Stand-Alone Simulator Describes invoke stand-alone simulator provides example. Invoking Stand-Alone Simulator Stand-Alone Simulator Options Using Profiling Capability Stand-Alone Simulator Selecting Silicon Revision Simulate (-rev Option) Stand-Alone Simulator Example TMS320C6000 C/C++ Language Implementation Discusses specific characteristics TMS320C6000 C/C++ compiler they relate ANSI specification. Characteristics TMS320C6000 7.1.1 Identifiers Constants 7.1.2 Data Types 7.1.3 Conversions 7.1.4 Expressions 7.1.5 Declarations 7.1.6 Preprocessor Characteristics TMS320C6000 Data Types Keywords 7.4.1 const Keyword 7.4.2 cregister Keyword 7.4.3 interrupt Keyword 7.4.4 near Keywords 7-10 7.4.5 restrict Keyword 7-13 7.4.6 volatile Keyword 7-14 Register Variables 7-15 Contents 7.10 Statement Pragma Directives 7.7.1 CODE_SECTION Pragma 7.7.2 DATA_ALIGN Pragma 7.7.3 DATA_MEM_BANK Pragma 7.7.4 DATA_SECTION Pragma 7.7.5 FUNC_CANNOT_INLINE Pragma 7.7.6 FUNC_EXT_CALLED Pragma 7.7.7 FUNC_INTERRUPT_THRESHOLD Pragma 7.7.8 FUNC_IS_PURE Pragma 7.7.9 FUNC_IS_SYSTEM Pragma 7.7.10 FUNC_NEVER_RETURNS Pragma 7.7.11 FUNC_NO_GLOBAL_ASG Pragma 7.7.12 FUNC_NO_IND_ASG Pragma 7.7.13 INTERRUPT Pragma 7.7.14 MUST_ITERATE Pragma 7.7.15 NMI_INTERRUPT Pragma 7.7.16 PROB_ITERATE Pragma 7.7.17 STRUCT_ALIGN Pragma 7.7.18 UNROLL Pragma Generating Linknames Initializing Static Global Variables Changing ANSI language Mode 7.10.1 Compatibility With (-pk Option) 7.10.2 Enabling Strict ANSI Mode Relaxed ANSI Mode (-ps Options) 7.10.3 Enabling Embedded Mode (-pe Option) 7-16 7-17 7-18 7-19 7-19 7-21 7-22 7-22 7-23 7-24 7-24 7-25 7-25 7-26 7-26 7-27 7-28 7-28 7-29 7-30 7-31 7-32 7-33 7-33 7-35 7-35 Run-Time Environment Discusses memory register conventions, stack organization, function-call conventions, system initialization. Provides information needed interfacing assembly language programs. Memory Model 8.1.1 Sections 8.1.2 C/C++ System Stack 8.1.3 Dynamic Memory Allocation 8.1.4 Initialization Variables 8.1.5 Memory Models 8.1.6 Position Independent Data Object Representation 8.2.1 Data Type Storage 8.2.2 Fields 8-14 8.2.3 Character String Constants 8-15 Register Conventions 8-16 Contents Contents Function Structure Calling Conventions 8.4.1 Function Makes Call 8.4.2 Called Function Responds 8.4.3 Accessing Arguments Local Variables Interfacing With Assembly Language 8.5.1 Using Assembly Language Modules With C/C++ Code 8.5.2 Using Intrinsics Access Assembly Language Statements 8.5.3 Using Unaligned Data 64-Bit Values 8.5.4 Using MUST_ITERATE _nassert Enable SIMD Expand Compiler Knowledge Loops 8.5.5 Side Effects 8.5.6 Using Inline Assembly Language 8.5.7 Accessing Assembly Language Variables From C/C++ Interrupt Handling 8.6.1 Saving Registers During Interrupts 8.6.2 Using C/C++ Interrupt Routines 8.6.3 Using Assembly Language Interrupt Routines Run-Time-Support Arithmetic Routines System Initialization 8.8.1 Automatic Initialization Variables 8.8.2 Global Constructors 8.8.3 Initialization Tables 8.8.4 Autoinitialization Variables Run-Time 8.8.5 Initialization Variables Load Time 8-18 8-18 8-19 8-21 8-22 8-22 8-25 8-34 8-34 8-36 8-37 8-38 8-40 8-40 8-40 8-41 8-42 8-44 8-45 8-45 8-46 8-49 8-50 Run-Time-Support Functions Describes libraries header files included with C/C++ compiler, well macros, functions, types that they-declare. Summarizes run-time-support functions according category (header). Provides alphabetical reference non-ANSI run-time-support functions. Libraries 9.1.1 Linking Code With Object Library 9.1.2 Modifying Library Function 9.1.3 Building Library With Different Options Functions 9.2.1 Overview Low-Level Implementation 9.2.2 Adding Device 9-11 Header Files 9-13 9.3.1 Diagnostic Messages (assert.h/cassert) 9-14 9.3.2 Character-Typing Conversion (ctype.h/cctype) 9-14 9.3.3 Error Reporting (errno.h/cerrno 9-15 9.3.4 Low-Level Input/Output Functions (file.h 9-15 9.3.5 Fast Macros/Static Inline Functions (gsm.h 9-15 9.3.6 Limits (float.h/cfloat limits.h/climits) 9-16 Contents 9.3.7 Function Calls near (linkage.h) 9.3.8 Floating-Point Math (math.h/cmath 9.3.9 Nonlocal Jumps (setjmp.h/csetjmp) 9.3.10 Variable Arguments (stdarg.h/cstdarg 9.3.11 Standard Definitions (sttdef.h/cstddef 9.3.12 Input/Output Functions (stdio.h/cstdio) 9.3.13 General Utilities (stdlib.h/cstdlib 9.3.14 String Functions (string.h/cstring 9.3.15 Time Functions (time.h/ctime 9.3.16 Exception Handling (exception stdexcept) 9.3.17 Dynamic Memory Management (new) 9.3.18 Run-Time Type Information (typeinfo) Saving On-Chip Memory Placing Run-Time-Support Off-Chip 9.4.1 Must #include Header File 9.4.2 Run-Time-Support Data 9.4.3 Link When Run-Time-Support Functions Off-Chip 9.4.4 Example Compiler Invocation When Run-Time-Support Off-Chip 9.4.5 Linker Error Messages When Calls Don't Reach 9.4.6 Changing Run-Time-Support Data near Summary Run-Time-Support Functions Macros Description Run-Time-Support Functions Macros 9-18 9-18 9-19 9-19 9-20 9-20 9-21 9-22 9-22 9-24 9-24 9-24 9-25 9-25 9-26 9-26 9-28 9-29 9-31 9-32 9-44 Library-Build Utility 10-1 Describes utility that custom-makes run-time-support libraries options used compile code. this utility install header files directory create custom libraries from source archives. 10.1 10.2 10.3 10.4 Standard Run-Time-Support Libraries Invoking Library-Build Utility Library-Build Utility Options Options Summary 10-2 10-3 10-4 10-5 Name Demangler 11-1 Describes name demangler tells invoke 11.1 11.2 11.3 Invoking Name Demangler 11-2 Name Demangler Options 11-2 Sample Usage Name Demangler 11-3 Glossary Defines terms acronyms used this book. Contents xiii Contents Figures 8-10 TMS320C6000 Software Development Flow Shell Program Overview Compiling C/C++ Program With Optimizer Software-Pipelined Loop 4-Bank Interleaved Memory 4-34 4-Bank Interleaved Memory With Memory Spaces 4-35 Char Short Data Storage Format 32-Bit Data Storage Format 8-10 40-Bit Data Storage Format 8-11 Double-Precision Floating-Point Data Storage Format 8-12 Field Packing Big-Endian Little-Endian Formats 8-14 Register Argument Conventions 8-19 Format Initialization Records .cinit Section 8-46 Format Initialization Records .cinit Section 8-48 Autoinitialization time 8-49 Initialization Load Time 8-50 Interaction Data Structures Functions First Three Streams Stream Table Contents Tables 10-1 Shell Options Summary Predefined Macro Names 2-24 Listing File Identifiers 2-34 Listing File Diagnostic Identifiers 2-35 Options That With 3-18 Selecting Level Option 3-18 Selecting Level Option 3-19 Selecting Level Option 3-20 Special Considerations When Using Option 3-21 Assembly Optimizer Directives Summary 4-16 Sections Created Compiler 5-11 TMS320C6000 C/C++ Data Types Valid Control Registers Data Representation Registers Memory Register Usage 8-17 TMS320C6000 C/C++ Compiler Intrinsics 8-25 Summary Run-Time-Support Arithmetic Functions 8-42 Macros That Supply Integer Type Range Limits (limits.h/climits) 9-16 Macros That Supply Floating-Point Range Limits (float.h/cfloat) 9-17 Summary Run-Time-Support Functions Macros 9-33 Summary Options Their Effects 10-5 Contents Contents Examples 4-10 4-11 4-12 4-13 4-14 4-15 4-16 4-17 Using inline keyword 2-37 Run-Time-Support Library Uses _INLINE Preprocessor Symbol 2-39 Interlisted Assembly Language File 2-43 Software Pipelining Information Function From Example Compiled With Options 3-30 Function From Example Compiled With -o2, -os, Options 3-31 Strength Reduction, Induction Variable Elimination, Register Variables, Software Pipelining 3-35 Control-Flow Simplification Copy Propagation 3-38 Data Flow Optimizations Expression Simplification 3-41 Inline Function Expansion 3-42 Register Tracking/Targeting 3-44 Code Computing Product Linear Assembly Code Computing Product 4-10 Software-Pipeline Kernel Computing Product With Example 4-11 Software Pipeline Information Example 4-12 Code From Example With Functional Unit Specifiers Added 4-13 Software-Pipeline Kernel Computing Product With Example 4-14 Lmac Function Code Showing Comments 4-15 Load Store Instructions That Specify Memory Bank Information 4-37 Code Product 4-38 Linear Assembly Product 4-39 Product Software-Pipelined Kernel 4-39 Product From Example 4-10 Unrolled Prevent Memory Bank Conflicts 4-40 Unrolled Product Kernel From Example 4-11 4-41 Using .mptr Indexed Pointers 4-42 Annotating Memory Reference 4-45 Software Pipeline Using .mdep ld1, 4-46 Software Pipeline Using .mdep st1, .mdep ld1, 4-46 Sample Linker Command File 5-13 Sample Stand-Alone Simulator Banners Profiling Product Routines Code With Clock Function Stand-Alone Simulator Results After Compiling Linking Example Define Control Registers restrict type qualifier with pointers 7-13 Contents 11-1 11-2 restrict type qualifier with arrays Using CODE_SECTION Pragma Using DATA_MEM_BANK Pragma Using DATA_SECTION Pragma Calling Assembly Language Function From Using Intrinsics Accessing Assembly Language Variable From Accessing Assembly Language Constant From Handling Initialization Table Run-Time-Support Linker Command File Name Mangling Result After Running Name Demangler Utility 7-13 7-18 7-20 7-21 8-24 8-34 8-38 8-39 8-41 8-47 9-27 11-3 11-5 Contents xvii Contents Notes Specifying Path Information Angle Brackets 2-27 Function Inlining Greatly Increase Code Size 2-36 Library Files Built With Option 2-41 Lower Optimization Level Control Code Size Option Applies Assembly Optimizer Software Pipelining Significantly Increase Code Size Turning Redundant Loops 3-15 Turning Redundant Loops 3-17 Disabling Code-Size Optimizations Reducing Optimization Level 3-17 Lower Optimization Level Control Code Size 3-18 Optimization Inlining 3-28 Inlining Code Size 3-28 Impact Performance Code Size 3-29 Option Causes Performance Code Size Degradations 3-32 Profile Points 3-33 Finer Grained Profiling 3-33 Scheduled Assembly Code Source Reserving Registers 4-30 Memory Dependency Exception 4-44 Memory Dependence/Bank Conflict 4-47 _c_int00 Symbol Avoid Disrupting C/C++ Environment With Statements 7-16 Linker Defines Memory Only Code Program Memory Stack Overflow Syntax _nassert 8-35 Using Statement 8-37 Initializing Variables 8-45 Unique Function Names 9-11 Writing Your Clock Function 9-23 Writing Your Clock Function 9-57 Previously Allocated Objects Available After minit 9-82 time Function Target-System Specific 9-110 xviii Chapter Introduction TMS320C6000 supported software development tools, which includes optimizing C/C++ compiler, assembly optimizer, assembler, linker, assorted utilities. This chapter provides overview these tools introduces features optimizing C/C++ compiler. assembly optimizer discussed Chapter assembler linker discussed detail TMS320C6000 Assembly Language Tools User's Guide. Topic Page Software Development Tools Overview C/C++ Compiler Overview Introduction Software Development Tools Overview Software Development Tools Overview Figure illustrates 'C6000 software development flow. shaded portion figure highlights most common path software development language programs. other portions peripheral functions that enhance development process. Figure 1-1. TMS320C6000 Software Development Flow C/C++ source files Macro source files C/C++ compiler Linear assembly Archiver Assembler source Assembly optimizer Macro library Assembler Assemblyoptimized file Archiver COFF object files Library-build utility Library object files Linker Run-Timesupport library conversion utility Executable COFF file Debugging tools EPROM programmer Cross-reference lister TMS320C6000 Software Development Tools Overview following list describes tools that shown Figure 1-1: assembly optimizer allows write linear assembly code without being concerned with pipeline structure with assigning registers. accepts assembly code that been register-allocated unscheduled. assembly optimizer assigns registers uses loop optimization turn linear assembly into highly parallel assembly that takes advantage software pipelining. Chapter Using Assembly Optimizer, information about invoking assembly optimizer, writing linear assembly code (.sa files), specifying functional units, using assembly optimizer directives. C/C++ compiler accepts C/C++ source code produces 'C6000 assembly language source code. shell program, optimizer, interlist utility parts compiler: shell program enables compile, assemble, link source modules step. input file extension, shell program invokes assembly optimizer. optimizer modifies code improve efficiency programs. interlist utility interweaves C/C++ source statements with assembly language output. Chapter Using C/C++ Compiler, information about invoke C/C++ compiler, optimizer, interlist utility using shell program. assembler translates assembly language source files into machine language object files. machine language based common object file format (COFF). TMS320C6000 Assembly Language Tools User's Guide explains assembler. linker combines object files into single executable object module. creates executable module, performs relocation resolves external references. linker accepts relocatable COFF object files object libraries input. Chapter Linking C/C++ Code, information about invoking linker. TMS320C6000 Assembly Language Tools User's Guide complete description linker. archiver allows collect group files into single archive file, called library. Additionally, archiver allows modify library deleting, replacing, extracting, adding members. most useful applications archiver building library object modules. TMS320C6000 Assembly Language Tools User's Guide explains archiver. Introduction Software Development Tools Overview library-build utility build your customized run- time-support library (see Chapter Library-Build Utility). Standard runtime-support library functions provided source code rts.src rstcpp.src. object code run-time-support functions compiled little-endian mode versus big-endian mode code versus code into standard libraries follows: little-endian code-rts6200.lib, rts6400.lib, rts6700.lib big-endian code-rts6200e.lib, rts6400e.lib, rts6700e.lib little-endian code-rtscpp6200.lib, rstcpp6400.lib, rtscpp6700.lib big-endian code-rtscpp6200e.lib, rstcpp6400e.lib, rtscpp6700e.lib run-time-support libraries contain ANSI standard run-time-support functions, compiler-utility functions, floating-point arithmetic functions, functions that supported 'C6000 compiler. Chapter Run-Time Environment. conversion utility converts COFF object file into TI-Tagged, ASCII-hex, Intel, Motorola-S, Tektronix object format. download converted file EPROM programmer. TMS320C6000 Assembly Language Tools User's Guide explains conversion utility. cross-reference lister uses object files produce cross-reference listing showing symbols, their definitions, their references linked source files. TMS320C6000 Assembly Language Tools User's Guide explains cross-reference utility. main product this development process module that executed TMS320C6000 device. several debugging tools refine correct your code. Available products include: instruction-accurate clock-accurate software simulator emulator information about these debugging tools, Code Composer User's Guide. C/C++ Compiler Overview C/C++ Compiler Overview 'C6000 C/C++ compiler full-featured optimizing compiler that translates standard ANSI programs into 'C6000 assembly language source. following subsections describe features compiler. 1.2.1 C/C++ Language Features ANSI-standard 'C6000 C/C++ compiler fully conforms ANSI standard defined ANSI specification described second edition Kernighan Ritchie's Programming Language (K&R). ANSI standard includes extensions that provide maximum portability increased capability. 'C6000 C/C++ compiler also supports defined Ellis Stroustrup's Annotated Reference Manual (ARM) many features X3J16/WG21 working paper. ANSI-standard run-time support compiler tools come with complete run-time library. library functions conform ANSI library standard. library includes functions standard input output, string manipulation, dynamic memory allocation, data conversion, timekeeping, trigonometry, exponential hyperbolic functions. Functions signal handling included, because these target-system specific. library includes ANSI subset well those components necessary language support. more information, Chapter Run-Time Environment. Introduction C/C++ Compiler Overview 1.2.2 Output Files following features pertain output files created compiler: Assembly source output compiler generates assembly language source files that inspect easily, enabling code generated from C/C++ source files. COFF object files Common object file format (COFF) allows define your system's memory link time. This maximizes performance enabling link C/C++ code data objects into specific memory areas. COFF also supports source-level debugging. Code initialize data into stand-alone embedded applications, compiler enables link code initialization data into ROM, allowing C/C++ code from reset. 1.2.3 Compiler Interface following features pertain interfacing with compiler: Compiler shell program compiler tools include shell program that compile, assembly optimize, assemble, link programs single step. more information, section 2.1, About Shell Program, page 2-2. Flexible assembly language interface compiler straightforward calling conventions, write assembly functions that call each other. more information, Chapter Run-Time Environment. C/C++ Compiler Overview 1.2.4 Compiler Operation following features pertain operation compiler: Integrated preprocessor C/C++ preprocessor integrated with parser, allowing faster compilation. Stand-alone preprocessing preprocessed listing also available. more information, section 2.5, Controlling Preprocessor, page 2-24. Optimization compiler uses sophisticated optimization pass that employs several advanced techniques generating efficient, compact code from C/C++ source. General optimizations applied C/C++ code, 'C6000-specific optimizations take advantage features specific 'C6000 architecture. more information about C/C++ compiler's optimization techniques, Chapter Optimizing Your Code. 1.2.5 Utilities following features pertain compiler utilities: Source interlist utility compiler tools include utility that interlists your original C/C++ source statements into assembly language output compiler. This utility provides with method inspecting assembly code generated each C/C++ statement. more information, section 2.12, Using Interlist Utility, page 2-42. Library-build utility library-build utility (mk6x) lets custom-build object libraries from source combination run-time models target CPUs. more information, Chapter Library-Build Utility. Stand-alone simulator stand-alone simulator (load6x) loads runs executable COFF .out file. When used with libraries, stand-alone simulator supports functions with standard output screen. more information, Chapter Using Stand-Alone Simulator. name demangler utility name demangler (dem6x) debugging that converts mangled names found output compiler tools (such assembly files linker error messages) back their original name declared source. more information, Chapter Name Demangler. Introduction Chapter Using C/C++ Compiler Translating your source program into code that 'C6000 execute multistep process. must compile, assemble, link your source files create executable object file. 'C6000 compiler tools contain special shell program, cl6x, that enables execute these steps with command. This chapter provides complete description shell program compile, assemble, link your programs. This chapter also describes preprocessor, inline function expansion features, interlist utility: Topic Page About Shell Program Invoking C/C++ Compiler Shell Changing Compiler's Behavior With Options Setting Default Shell Options (C_OPTION C6X_C_OPTION) 2-23 Controlling Preprocessor 2-24 Understanding Diagnostic Messages 2-29 Other Messages 2-33 Generating Cross-Reference Listing Information (-px Option) 2-33 Generating Listing File (-pl Option) 2-34 2.10 Using Inline Function Expansion 2-36 2.11 Interrupt Flexibility Options (-min Option) 2-41 2.12 Using Interlist Utility 2-42 Using C/C++ Compiler About Shell Program About Shell Program compiler shell program (cl6x) lets compile, assemble, optionally link step. shell runs more source modules through following: compiler, which includes parser, optimizer, code generator, accepts source code produces 'C6000 assembly language source code. compile files single command. compiler uses conventions filename extensions distinguish between different file types. section 2.3.2, Specifying Filenames, more information. assembler generates COFF object file. linker links your files create executable object file. linker optional with shell. compile assemble various files with shell link them later. Chapter Linking C/C++ Code, information about linking files separate step. default, shell compiles assembles files; however, also link files using shell option. Figure illustrates path shell takes with without using linker. About Shell Program Figure 2-1. Shell Program Overview C/C++ source files C/C++ compiler Parser Optimizer (optional) Assembly optimizer Assembly preprocessor Code generator Assembler source With linker option (-z) Assembler Linker COFF object files Executable COFF file complete description assembler linker, TMS320C6000 Assembly Language Tools User's Guide. Using C/C++ Compiler Invoking C/C++ Compiler Shell Invoking C/C++ Compiler Shell invoke compiler shell, enter: cl6x [options] [filenames] [link_options] [object files]] cl6x Command that runs compiler assembler Options that affect shell processes input files. options listed Table page 2-7. more C/C++ source files, assembly language source files, linear assembly files, object files Option that invokes linker. Chapter Linking C/C++ Code, more information about invoking linker. Options that control linking process Name additional object files linking process options filenames link_options object files option associated information (linker options object files) must follow filenames compiler options command line. specify other options (except linker options) filenames order command line. example, want compile files named symtab.c file.c, assemble third file named seek.asm, assembly optimize fourth file named find.sa, suppress progress messages (-q), enter: cl6x symtab.c file.c seek.asm find.sa cl6x encounters each source file, prints C/C++ filenames square brackets assembly language filenames angle brackets linear assembly files braces This example uses option suppress additional progress information that cl6x produces. Entering this command produces these messages: [symtab.c] [file.c] <seek.asm> {find.sa} Invoking C/C++ Compiler Shell normal progress information consists banner each compiler pass names functions they processed. example below shows output from compiling single file (symtab) without option: cl6x symtab.c [symtab.c] TMS320C6x ANSI C/C++ Compiler Version Copyright 1996-2000 Texas Instruments Incorporated "symtab.c" symtab TMS320C6x ANSI C/C++ Codegen Version Copyright 1996-2000 Texas Instruments Incorporated "symtab.c": symtab TMS320C6x COFF Assembler Version Copyright 1996-2000 Texas Instruments Incorporated PASS PASS Errors, Warnings Using C/C++ Compiler Changing Compiler's Behavior With Options Changing Compiler's Behavior With Options Options control operation both shell programs runs. This section provides description option conventions option summary table. also provides detailed descriptions most frequently used options, including options used type-checking assembling. following apply compiler options: Options case sensitive. Options preceded hyphen. Single-letter options without parameters combined. example, -sgq equivalent Two-letter pair options that have same first letter combined. example, -pk, -pl, combined -pklm. Options that have parameters, such -uname -idirectory, cannot combined. They must specified separately. Options with parameters have space between option rameter right next each other. example, option undefine name expressed name -uname. Files options occur order except option. tion must follow other compiler options precede linker options. define default options shell using C_OPTION C6X_C_OPTION environment variable. detailed description these environment variables, section 2.4, Setting Default Shell Options (C_OPTION C6X_C_OPTION), page 2-23. Table summarizes options (including linker options). page references table more complete descriptions options. online summary options, enter cl6x with parameters command line. Changing Compiler's Behavior With Options Table 2-1. Shell Options Summary Options that control compiler shell Option -@filename -dname [=def -idirectory Effect Interprets contents file extension command line Disables linking (negates Predefines name Enables symbolic debugging Defines #include search path Keeps assembly language (.asm) file Compiles assembly optimizes only Suppresses progress messages (quiet) Suppresses messages (super quiet) Interlists optimizer comments available) assembly source statements; otherwise interlists assembly source statements Interlists source assembly statements Undefines name Enables linking Page 2-15 2-15, 2-15 2-15 2-15, 2-26 2-15 2-16 2-16 2-16 2-16 -uname 2-17, 3-29 2-17 2-17 Using C/C++ Compiler Changing Compiler's Behavior With Options Table 2-1. Shell Options Summary (Continued) Options that change default file extensions Option -ea[.]extension -el[.]extension -eo[.]extension Effect Sets default extension assembly source files Sets default extension assembly optimizer source files Sets default extension object files Page 2-20 2-20 2-20 Options that specify files Option -fafilename Effect Identifies filename assembly source file regardless extension. default, compiler assembler treat .asm files assembly source files. Identifies filename source file regardless extension. default, compiler treats files source files. Processes filename file. Identifies filename linear assembly source file regardless extension. default, compiler assembly optimizer treat files linear assembly source files. Identifies filename object code file regardless extension. default, compiler linker treat .obj files object code files. Identifies filename file, regardless extension. default, compiler treats .cpp, .cxx files files. Page 2-19 -fcfilename 2-19 -fgfilename -flfilename 2-19 2-19 -fofilename 2-19 filename 2-19 Options that specify directories Option -fbdirectory -ffdirectory -frdirectory -fsdirectory -ftdirectory Effect Specifies absolute listing file directory Specifies assembly listing file cross-reference listing file directory Specifies object file directory Specifies assembly file directory Specifies temporary file directory Page 2-21 2-21 2-21 2-21 2-21 Changing Compiler's Behavior With Options Table 2-1. Shell Options Summary (Continued) Options that machine-specific Option -mhn -min -mln -mrn -msn -mvn Effect Indicates that specific aliasing technique used Prevents reordering associative floating-point operations Produces object code big-endian format. Allows profile optimized code Allows speculative execution Specifies interrupt threshold value Changes near assumptions four levels (-ml0, -ml1, -and ml2, -ml3) Make calls run-time-support functions near (-mr0) (-mr1) Controls code size four levels (-ms0, -ms1, -ms2, -ms3) Indicates that specific aliasing techniques used Turns software pipelining Selects target version Page 3-24 3-27 2-15 3-33 3-13 2-41 2-16 7-11 3-17 3-25, 4-44 3-15 Using C/C++ Compiler Changing Compiler's Behavior With Options Table 2-1. Shell Options Summary (Continued) Options that control parsing Option Effect Enables embedded mode Disables definition-controlled inlining (but optimizations still perform automatic inlining) Allows compatibility Generates listing file Combines source files perform program-level optimization Enables relaxed mode; ignores strict ANSI violations Enables strict ANSI mode (for C/C++, Generates cross-reference listing file Page 7-35 2-38 7-33 2-34 3-20 7-35 7-35 2-33 Parser options that control preprocessing Option -ppa -ppc Effect Continues compilation after preprocessing Performs preprocessing only. Writes preprocessed output, keeping comments, file with same name input with extension Performs preprocessing only, instead writing preprocessed output, writes list dependency lines suitable input standard make utility Performs preprocessing only, instead writing preprocessed output, writes list files included with #include directive Performs preprocessing only. Writes preprocessed output with line-control information (#line directives) file with same name input with extension Performs preprocessing only. Writes preprocessed output file with same name input with extension Page 2-27 2-28 -ppd 2-28 -ppi 2-28 -ppl 2-28 -ppo 2-27 2-10 Changing Compiler's Behavior With Options Table 2-1. Shell Options Summary (Continued) Parser options that control diagnostics Option -pdel Effect Sets error limit num. compiler abandons compiling after this number errors. (The default 100.) Displays diagnostic's identifiers along with text Generates diagnostics information file Issues remarks (nonserious warnings) Suppresses diagnostic identified Categorizes diagnostic identified error Categorizes diagnostic identified remark Categorizes diagnostic identified warning Provides verbose diagnostics that display original source with line-wrap Suppresses warning diagnostics (errors still issued) Page 2-31 -pden -pdf -pdr -pds -pdse -pdsr -pdsw -pdv -pdw 2-31 2-31 2-31 2-31 2-31 2-31 2-31 2-32 2-32 Using C/C++ Compiler 2-11 Changing Compiler's Behavior With Options Table 2-1. Shell Options Summary (Continued) Options that control optimization Option -oisize -ol0 -oL0 -ol1 -oL1 -ol2 -oL2 Effect Optimizes register usage Uses optimizations optimizes locally Uses optimizations optimizes globally Uses optimizations optimizes file Sets automatic inlining size (-o3 only). size specified, default Informs optimizer that your file alters standard library function Informs optimizer that your file declares standard library function Informs optimizer that your file does declare alter library functions. Overrides -ol0 -ol1 options (default). Disables optimization information file Produces optimization information file Produces verbose optimization information file Specifies that module contains functions variables that called modified from outside source code provided compiler Specifies that module contains variables modified from outside source code provided compiler does functions called from outside source code Specifies that module contains functions variables that called modified from outside source code provided compiler (default) Specifies that module contains functions that called from outside source code provided compiler does variables modified from outside source code Interlists optimizer comments with assembly statements Page 3-28 3-18 3-18 3-18 -on0 -on1 -on2 -op0 3-19 3-19 3-19 3-20 -op1 3-20 -op2 3-20 -op3 3-20 3-29 machine-specific -ma, -mhn, -min, -msn, options, Table 2-1(e), also effect optimization. 2-12 Changing Compiler's Behavior With Options Table 2-1. Shell Options Summary (Continued) Options that control assembler Option -adname -ahcfilename -ahifilename -auname Effect Enables absolute listing Makes case significant assembly source files Sets name symbol. Copies specified file assembly module Includes specified file assembly module Generates assembly listing file Puts labels symbol table Undefines predefined constant name Generates cross-reference file Page 2-22 2-22 2-22 2-22 2-22 2-22 2-22 2-22 2-22 Using C/C++ Compiler 2-13 Changing Compiler's Behavior With Options Table 2-1. Shell Options Summary (Continued) Options that control linker Options global_symbol fill_value global_symbol -heap size directory libraryname filename name.out -stack size symbol Effect Generates absolute executable output Generates relocatable executable output Disables merge symbolic debugging information. Autoinitializes variables run-time Initializes variables loadtime Defines entry point Defines fill value Keeps global_symbol global (overrides Makes global symbols static Sets heap size (bytes) Defines library search path Supplies library command filename Names file Ignores fill specifications MEMORY directives Names output file Suppresses progress messages (quiet) Generates relocatable nonexecutable output Strips symbol table information line number entries from output module Sets stack size (bytes) Undefines symbol Displays message when undefined output section created Forces rereading libraries Page 5-2, 8-44 5-2, 8-44 2-14 Changing Compiler's Behavior With Options 2.3.1 Frequently Used Options Following detailed descriptions options that will probably frequently: -@filename Appends contents file command line. this option avoid limitations command line length style comments imposed host operating system. beginning line command file include comments. also include comments delimiting them with Suppresses linker overrides option, which specifies linking. this option when have specified C_OPTION C6X_C_OPTION environment variable want link. more information, section 5.3, Disabling Linker Shell Option), page 5-5. Predefines constant name preprocessor. This equivalent inserting #define name each source file. optional [=def omitted, name Generates symbolic debugging directives that used C/C++ source-level debugger enables assembly source debugging assembler. option with option maximize amount optimization that compatible with debugging (see section 3.12.1, Debugging Optimized Code Options), page 3-32). However, option disables many optimizations, because they disrupt debugger. Adds directory list directories that compiler searches #include files. this option maximum times define several directories; sure separate options with spaces. specify directory name, preprocessor ignores option. more information, section 2.5.2.1, Changing #include File Search Path With Option, page 2-26. Retains assembly language output from compiler assembly optimizer. Normally, shell deletes output assembly language file after assembly complete. Produces code big-endian format. default, little-endian code produced. -dname[=def] -idirectory Using C/C++ Compiler 2-15 Changing Compiler's Behavior With Options -mln Generates large-memory model code four levels (-ml0, -ml1, -ml2, -ml3): -ml0 defaults aggregate data (structs arrays) -ml1 defaults function calls -ml2 defaults aggregate data calls -ml3 defaults data calls level specified, data functions default near. Near data accessed data page pointer more efficiently while near calls executed more efficiently using relative branch. these options have much static extern data within 15-bit scaled offset from beginning .bss section, have calls where called function more than $1024 words away from call site. linker issues error message when these situations occur. section 7.4.4, near Keywords, page 7-10, section 8.1.5, Memory Models, page 8-6, more information. Selects target version (For more information about option, page 3-15.) Compiles assembly optimizes only. specified source files compiled assembly optimized assembled linked. This option overrides output assembly language output from compiler. Suppresses banners progress information from tools. Only source filenames error messages output. Suppresses output except error messages Invokes interlist utility, which interweaves optimizer comments C/C++ source with assembly source. optimizer invoked (-on option), optimizer comments interlisted with assembly language output compiler. optimizer invoked, C/C++ source statements interlisted with assembly language output compiler, which allows inspect code generated each C/C++ statement. option implies option.The option have negative performance and/ code size impact. 2-16 Changing Compiler's Behavior With Options Invokes interlist utility, which interweaves original C/C++ source with compiler-generated assembly language. interlisted statements appear sequence. interlist utility with optimizer combining options. more information, section 2.12, Using Interlist Utility, page 2-42.The option have negative performance and/or code size impact. Undefines predefined constant name. This option overrides options specified constant. Runs linker specified object files. option parameters follow other options command line. arguments that follow passed linker. more information, section 5.1, Invoking Linker Individual Program, page 5-2. -uname Using C/C++ Compiler 2-17 Changing Compiler's Behavior With Options 2.3.2 Specifying Filenames input files that specify command line source files, source files, assembly source files, linear assembly files, object files. shell uses filename extensions determine file type. Extension .cpp, .cxx, .asm, .abs, (extension begins with .obj File Type source source Linear assembly Assembly source Object Case sensitivity filename extensions determined your operating system. your operating system case sensitive, interpreted file. conventions filename extensions allow compile files optimize assemble assembly files with single command. information about alter that shell interprets individual filenames, section 2.3.3 page 2-19. information about alter that shell interprets names extensions assembly source object files, section 2.3.5 page 2-21. wildcard characters compile assemble multiple files. Wildcard specifications vary system; appropriate form listed your operating system manual. example, compile files directory with extension .cpp, enter following: cl6x *.cpp 2-18 Changing Compiler's Behavior With Options 2.3.3 Changing Shell Program Interprets Filenames (-fa, -fc, -fg, -fl, -fo, Options) options change shell interprets your filenames. extensions that different from those recognized shell, -fa, -fc, -fl, -fo, options specify type file. insert optional space between option filename. Select appropriate option type file want specify: -fafilename -fcfilename -flfilename -fofilename -fpfilename assembly language source file source file linear assembly file object file source file example, have source file called file.s assembly language source file called assy, options force correct interpretation: cl6x file.s assy cannot -fa, -fc, -fl, options with wildcard specifications. option causes compiler process files files. default, compiler treats files with extension files. section 2.3.2, Specifying Filenames, page 2-18, more information about filename extension conventions. Using C/C++ Compiler 2-19 Changing Compiler's Behavior With Options 2.3.4 Changing Shell Program Interprets Names Extensions (-ea, -el, Options) options change shell program interprets filename extensions names extensions files that creates. -ea, -el, options must precede filenames they apply command line. wildcard specifications with these options. extension nine characters length. Select appropriate option type extension want specify: -ea[.] extension -el[.] extension -eo[.] extension assembly language file assembly optimizer file object file following example assembles file fit.rrr creates object file named fit.o: cl6x .rrr fit.rrr period extension space between option extension optional. also write example above cl6x -earrr -eoo fit.rrr 2-20 Changing Compiler's Behavior With Options 2.3.5 Specifying Directories (-fb, -ff, -fr, -fs, Options) default, shell program places object, assembly, temporary files that creates into current directory. want shell program place these files different directories, following options: -fbdirectory Specifies destination directory absolute listing files. default same directory object file directory. specify absolute listing file directory, type directory's pathname command line after option: cl6x d:\abso_list -ffdirectory Specifies destination directory assembly listing files cross-reference listing files. default same directory object file directory. specify assembly/cross-reference listing file directory, type directory's pathname command line after option: cl6x d:\listing -frdirectory Specifies directory object files. specify object file directory, type directory's pathname command line after option: cl6x d:\object -fsdirectory Specifies directory assembly files. specify assembly file directory, type directory's pathname command line after option: cl6x d:\assembly -ftdirectory Specifies directory temporary intermediate files. specify temporary directory, type directory's pathname command line after option: cl6x c:\temp Using C/C++ Compiler 2-21 Changing Compiler's Behavior With Options 2.3.6 Options That Control Assembler Following assembler options that with shell: Invokes assembler with assembler option, which creates absolute listing. absolute listing shows absolute addresses object code. makes case insignificant assembly language source files. example, makes symbols equivalent. this option, case significant (this default). -dname [=value] sets name symbol. This equivalent inserting name .set [value] beginning assembly file. value omitted, symbol Invokes assembler with assembler option tell assembler copy specified file assembly module. file inserted before source file statements. copied file appears assembly listing files. Invokes assembler with assembler option tell assembler include specified file assembly module. file included before source file statements. included file does appear assembly listing files. Invokes assembler with (lowercase assembler option produce assembly listing file. Invokes assembler with assembler option labels symbol table. Label definitions written COFF symbol table with symbolic debugging. Undefines predefined constant name, which overrides options specified constant. Invokes assembler with assembler option produce symbolic cross-reference listing file. -adname -ahcfilename -ahifilename -auname more information about assembler options, TMS320C6000 Assembly Language Tools User's Guide. 2-22 Setting Default Shell Options (C_OPTION C_C6X_OPTION) Setting Default Shell Options (C_OPTION C_C6X_OPTION) might find useful compiler, assembler, linker shell default options using C6X_C_OPTION C_OPTION environment variable. this, shell uses default options and/or input filenames that name with C6X_C_OPTION C_OPTION every time shell. Setting default options with these environment variables useful when want shell consecutive times with same options and/or input files. After shell reads command line input filenames, looks C6X_C_OPTION environment variable first then reads processes does find C6X_C_OPTION, reads C_OPTION environment variable processes table below shows C_OPTION environment variable. Select command your operating system: Operating System UNIX with shell UNIX with Bourne Korn shell Windowst Enter setenv C_OPTION "option1 [option2 C_OPTION="option1 [option2 export C_OPTION C_OPTION=option1 [;option2 Environment variable options specified same have same meaning they command line. example, want always quietly (the option), enable C/C++ source interlisting (the option), link (the option) Windows, C_OPTION environment variable follows: C_OPTION=-qs following examples, each time compiler shell, runs linker. options following command line C_OPTION passed linker. This enables C_OPTION environment variable specify default compiler linker options then specify additional compiler linker options shell command line. have environment variable want compile only, option shell. These additional examples assume C_OPTION shown above: cl6x cl6x cl6x cl6x lnk.cmd lnk.cmd compiles links only compiles compiles links using command file only compiles overrides more information about shell options, section 2.3, Changing Compiler's Behavior With Options, page 2-6. more information about linker options, section 5.4, Linker Options, page 5-6. Using C/C++ Compiler 2-23 Controlling Preprocessor Controlling Preprocessor This section describes specific features that control 'C6000 preprocessor, which part parser. general description preprocessing section K&R. 'C6000 C/C++ compiler includes standard C/C++ preprocessing functions, which built into first pass compiler. preprocessor handles: Macro definitions expansions #include files Conditional compilation Various other preprocessor directives (specified source file lines beginning with character) preprocessor produces self-explanatory error messages. line number filename where error occurred printed along with diagnostic message. 2.5.1 Predefined Macro Names compiler maintains recognizes predefined macro names listed Table 2-2. Table 2-2. Predefined Macro Names Macro Name _TMS320C6X _TMS320C6200 _TMS320C6400 _TMS320C6700 _LITTLE_ENDIAN _BIG_ENDIAN _LARGE_MODEL _LARGE_MODEL_OPTION _SMALL_MODEL Specified ANSI standard Description Always defined Defined target '6200 Defined target '6400 Defined target '6700 Defined little-endian mode selected (the option used); otherwise, undefined Defined big-endian mode selected (the option used); otherwise, undefined Defined large-model mode selected (the option used); otherwise, undefined large-model specified -mln; otherwise, undefined. Defined small-model mode selected (the option used); otherwise, undefined 2-24 Controlling Preprocessor Table 2-2. Predefined Macro Names (Continued) Macro Name _LINE_ _FILE_ _DATE_ _TIME_ _INLINE Description Expands current line number Expands current source filename Expands compilation date form yyyy Expands compilation time form hh:mm:ss Expands optimization used; undefined otherwise. Regardless optimization, always undefined when used. Defined indicate that compiler conforms ANSI Standard. section 7.1, Characteristics TMS320C6000 page 7-2, exceptions ANSI conformance. _STDC_ Specified ANSI standard names listed Table same manner other defined name. example, printf _TIME_ _DATE_ translates line such printf ("%s "13:58:17", "Jan 1997"); 2.5.2 Search Path #include Files #include preprocessor directive tells compiler read source statements from another file. When specifying file, enclose filename double quotes angle brackets. filename complete pathname, partial path information, filename with path information. enclose filename double quotes compiler searches file following directories this order: directory that contains current source file. current source file refers file that being compiled when compiler encounters #include directive. Directories named with option Directories with C_DIR C6X_C_DIR environment variable Using C/C++ Compiler 2-25 Controlling Preprocessor enclose filename angle brackets compiler searches file following directories this order: Directories named with option Directories with C_DIR C6X_C_DIR environment variable section 2.5.2.1, Changing #include File Search Path Option) information using option. code generation tools CD-ROM insert information C_DIR environment variable. 2.5.2.1 Changing #include File Search Path Option) option names alternate directory that contains #include files. format option directory1 directory2 options invocation compiler; each option names directory. source, #include directive without specifying directory information file; instead, specify directory information with option. example, assume that file called source.c current directory. file source.c contains following directive statement: #include "alt.h" Assume that complete pathname alt.h UNIX Windows /6xtools/files/alt.h c:\6xtools\files\alt.h table below shows invoke compiler. Select command your operating system: Operating System UNIX Windows Enter cl6x -i/6xtools/files source.c cl6x -ic:\6xtools\files source.c 2-26 Controlling Preprocessor Note: Specifying Path Information Angle Brackets specify path information angle brackets, compiler applies that information relative path information specified with options C_DIR C6X_C_DIR environment variable. example, C_DIR with following command: setenv C_DIR "/usr/include;/usr/ucb" invoke compiler with following command: cl6x -i/usr/include file.c file.c contains this line: #include <sys/proc.h> result that included file following path: /usr/include/sys/proc.h 2.5.3 Generating Preprocessed Listing File (-ppo Option) -ppo option allows generate preprocessed version your source file, with extension .pp. compiler's preprocessing functions perform following operations source file: Each source line ending backslash joined with following line. Trigraph sequences expanded. Comments removed. #include files copied into file. Macro definitions processed. macros expanded. other preprocessing directives, including #line directives condi- tional compilation, expanded. 2.5.4 Continuing Compilation After Preprocessing (-ppa Option) preprocessing, preprocessor performs preprocessing only. default, does compile your source code. want override this feature continue compile after your source code preprocessed, -ppa option along with other preprocessing options. example, -ppa with -ppo perform preprocessing, write preprocessed output file with extension, then compile your source code. Using C/C++ Compiler 2-27 Controlling Preprocessor 2.5.5 Generating Preprocessed Listing File With Comments (-ppc Option) -ppc option performs preprocessing functions except removing comments generates preprocessed version your source file with extension. -ppc option instead -ppo option want keep comments. 2.5.6 Generating Preprocessed Listing File With Line-Control Information (-ppl Option) default, preprocessed output file contains preprocessor directives. want include #line directives, -ppl option. -ppl option performs preprocessing only writes preprocessed output with line-control information (#line directives) file with same name source file with extension. 2.5.7 Generating Preprocessed Output Make Utility (-ppd Option) -ppd option performs preprocessing only, instead writing preprocessed output, writes list dependency lines suitable input standard make utility. list written file with same name source file with extension. 2.5.8 Generating List Files Included With #include Directive (-ppi Option) -ppi option performs preprocessing only, instead writing preprocessed output, writes list files included with #include directive. list written file with same name source file with extension. 2-28 Understanding Diagnostic Messages Understanding Diagnostic Messages compiler's primary functions report diagnostics source program. When compiler detects suspect condition, displays message following format: "file.c", line diagnostic severity: diagnostic message "file.c" line name file involved line number where diagnostic applies severity diagnostic message description each severity category follows) diagnostic severity diagnostic message text that describes problem Diagnostic messages have associated severity, follows: fatal error indicates problem such severity that compilation can- continue. Examples problems that cause fatal error include command-line errors, internal errors, missing include files. multiple source files being compiled, source files after current will compiled. error indicates violation syntax semantic rules C/C++ language. Compilation continues, object code generated. warning indicates something that valid questionable. Compilation continues object code generated errors detected). remark less serious than warning. indicates something that valid probably intended, need checked. Compilation continues object code generated errors detected). default, remarks issued. -pdr shell option enable remarks. Diagnostics written standard error with form like following example: "test.c", line error: break statement only used within loop switch break; default, source line omitted. -pdv shell option enable display source line error position. above example makes this option. message identifies file line involved diagnostic, source line itself (with position indicated character) follows message. several diagnostics apply source line, each diagnostic form shown; text source line displayed several times, with appropriate position indicated each time. Using C/C++ Compiler 2-29 Understanding Diagnostic Messages Long messages wrapped additional lines, when necessary. command-line option (-pden) request that diagnostic's numeric identifier included diagnostic message. When displayed, diagnostic identifier also indicates whether diagnostic have severity overridden command line. severity overridden, diagnostic identifier includes suffix (for discretionary); otherwise, suffix present. example: "Test_name.c", line error #64-D: declaration does declare anything struct "Test_name.c", line error #77: this declaration storage class type specifier xxxxx; Because error determined discretionary based error severity associated with specific context, error discretionary some cases others. warnings remarks discretionary. some messages, list entities (functions, local variables, source files, etc.) useful; entities listed following initial error message: "test.c", line error: more than instance overloaded function matches argument list: function "f(int)" function "f(float)" argument types are: (double) f(1.5); some cases, additional context information provided. Specifically, context information useful when front issues diagnostic while doing template instantiation while generating constructor, destructor, assignment operator function. example: "test.c", line error: "A::A()" inaccessible detected during implicit generation "B::B()" line Without context information, difficult determine what error refers. 2-30 Understanding Diagnostic Messages 2.6.1 Controlling Diagnostics C/C++ compiler provides diagnostic options that allow modify parser interprets your code. These options control diagnostics: -pdel Sets error limit num, which decimal value. compiler abandons compiling after this number errors. (The default 100.) Displays diagnostic's numeric identifier along with text. this option determining which arguments need supply diagnostic suppression options (-pds, -pdse, -pdsr, -pdsw). This option also indicates whether diagnostic discretionary. discretionary diagnostic whose severity overridden. discretionary diagnostic includes suffix otherwise, suffix present. section 2.6, Understanding Diagnostic Messages, page 2-29 more information. -pdf -pdr -pds Produces diagnostics information file with same name corresponding source file with .err extension Issues remarks (nonserious warnings), which suppressed default Suppresses diagnostic identified num. determine numeric identifier diagnostic message, -pden option first separate compile. Then -pds suppress diagnostic. suppress only discretionary diagnostics. -pden -pdse Categorizes diagnostic identified error. determine numeric identifier diagnostic message, -pden option first separate compile. Then -pdse recategorize diagnostic error. alter severity discretionary diagnostics only. -pdsrnum Categorizes diagnostic identified remark. determine numeric identifier diagnostic message, -pden option first separate compile. Then -pdsr recategorize diagnostic remark. alter severity discretionary diagnostics only. Categorizes diagnostic identified warning. determine numeric identifier diagnostic message, -pden option first separate compile. Then -pdsw recategorize diagnostic warning. alter severity discretionary diagnostics only. -pdsw Using C/C++ Compiler 2-31 Understanding Diagnostic Messages -pdv Provides verbose diagnostics that display original source with line-wrap indicate position error source line Suppresses warning diagnostics (errors still issued) -pdw 2.6.2 Diagnostic Suppression Options following example demonstrates control diagnostic messages issued compiler. Consider following code segment: one(); main() switch (i){ case return break; default: return break; invoke compiler with option, this result: "err.c", line warning: statement unreachable "err.c", line warning: statement unreachable Because standard programming practice include break statements each case avoid fall-through condition, these warnings ignored. Using -pden option, find diagnostic identifier these warnings. Here result: [err.c] "err.c", line warning #111-D: statement unreachable "err.c", line warning #111-D: statement unreachable Next, diagnostic identifier argument -pdsr option treat this warning remark. This compilation produces diagnostic messages (because remarks disabled default). Although this type control useful, also extremely dangerous. compiler often emits messages that indicate less than obvious problem. careful analyze diagnostics emitted before using suppression options. 2-32 Other Messages Generating Cross-Reference Listing Information (-px Option) Understanding Diagnostic Messages Other Messages Other Messages Other error messages that unrelated source, such incorrect command-line syntax inability find specified files, usually fatal. They identified symbol preceding message. Generating Cross-Reference Listing Information (-px Option) option generates cross-reference listing file that contains reference information each identifier source file. (The option separate from -ax, which assembler rather than shell option.) cross-reference listing file same name source file with .crl extension. information cross-reference listing file displayed following format: sym-id name filename line number column number sym-id name integer uniquely assigned each identifier identifier name following values: Value Meaning Definition Declaration (not definition) Modification Address taken Used Changed (used modified single operation) other kind reference Error; reference indeterminate filename line number column number source file line number source file column number source file Using C/C++ Compiler 2-33 Generating Listing File (-pl Option) Generating Listing File (-pl Option) option generates listing file that help understand compiler preprocessing your source file. Whereas preprocessed listing file (generated with -ppo, -ppc, -ppl, -ppf preprocessor options) shows preprocessed version your source file, listing file provides comparison between original source line preprocessed output. listing file same name corresponding source file with extension. listing file contains following information: Each original source line Transitions into include files Diagnostics Preprocessed source line nontrivial processing performed (com- ment removal considered trivial; other preprocessing nontrivial) Each source line listing file begins with identifiers listed Table 2-3. Table 2-3. Listing File Identifiers Identifier Definition Normal line source Expanded line source. appears immediately following normal line source nontrivial preprocessing occurs. Skipped source line (false clause) Change source position, given following format: line number filename Where line number line number source file. present only when change entry/exit include file. Possible values follows: entry into include file exit from include file 2-34 Generating Listing File (-pl Option) option also includes defined Table 2-4. Table 2-4. Listing File Diagnostic Identifiers Diagnostic identifier Definition Error Fatal Remark Warning Diagnostic listing information displayed following format: filename line number column number diagnostic filename line number column number diagnostic identifiers Table that indicates severity diagnostic source file line number source file column number source file message text diagnostic Diagnostics after file indicated last line file with column number When diagnostic message text requires more than line, each subsequent line contains same file, line, column information uses lowercase version diagnostic identifier. more information about diagnostic messages, section 2.6, Understanding Diagnostic Messages, page 2-29. Using C/C++ Compiler 2-35 Using Inline Function Expansion 2.10 Using Inline Function Expansion When inline function called, C/C++ source code function inserted point call. This known inline function expansion. Inline function expansion advantageous short functions following reasons: saves overhead function call. Once inlined, optimizer free optimize function context with surrounding code. There several types inline function expansion: Inlining with intrinsic operators (intrinsics always inlined) Automatic inlining Definition-controlled inlining with unguarded inline keyword Definition-controlled inlining with guarded inline keyword Note: Function Inlining Greatly Increase Code Size Expanding functions inline increases code size, especially inlining function that called number places. Function inlining optimal functions that called only from small number places small functions. your code size seems large, section 3.4, Reducing Code Size (-ms Option), page 3-17. 2.10.1 Inlining Intrinsic Operators There many intrinsic operators 'C6000. them automatically inlined compiler. inlining happens automatically whether optimizer. details about intrinsics, list intrinsics, section 8.5.2, Using Intrinsics Access Assembly Language Statements, page 8-25. 2.10.2 Automatic Inlining When compiling C/C++ source code with option, inline function expansion performed small functions more information, section 3.10, Automatic Inline Expansion (-oi Option), page 3-28. 2-36 Using Inline Function Expansion 2.10.3 Unguarded Definition-Controlled Inlining inline keyword specifies that function expanded inline point which called rather than using standard calling procedures. compiler performs inline expansion functions declared with inline keyword. must invoke optimizer with option (-o0, -o1, -o2, -o3) turn definition-controlled inlining. Automatic inlining also turned when using -o3. following example shows usage inline keyword, where function call replaced code called function. Example 2-1. Using inline keyword inline volume_sphere(float return 4.0/3.0 foo(.) volume volume_sphere(radius); option turns definition-controlled inlining. This option useful when need certain level optimization want definition-controlled inlining. Using C/C++ Compiler 2-37 Using Inline Function Expansion 2.10.4 Guarded Inlining _INLINE Preprocessor Symbol When declaring function header file static inline, additional procedures should followed avoid potential code size increase when inlining turned with optimizer run. order prevent static inline function header file from causing increase code size when inlining gets turned off, following procedure. This allows external-linkage when inlining turned off; thus, only function definition will exist throughout object files. Prototype static inline version function. Then, prototype alterna- tive, nonstatic, externally-linked version function. Conditionally preprocess these prototypes with _INLINE preprocessor symbol, shown Example 2-2. Create identical version function definition .cpp file, shown Example 2-2. Example there definitions strlen function. first, header file, inline definition. This definition enabled prototype declared static inline only _INLINE true (_INLINE automatically defined when optimizer used specified). second definition, library, ensures that callable version strlen exists when inlining disabled. Since this inline function, _INLINE preprocessor symbol undefined (#undef) before string.h included generate noninline version strlen's prototype. 2-38 Using Inline Function Expansion Example 2-2. Run-Time-Support Library Uses _INLINE Preprocessor Symbol string.h string.h vx.xx Copyright 1993-1999 Texas Instruments Incorporated Excerpted #ifdef _INLINE #define _IDECL static inline #else #define _IDECL extern _CODE_ACCESS #endif _IDECL size_t #ifdef _INLINE strlen static inline size_t strlen(const char *string) size_t (size_t)-1; const char string n++; while (*++s); return #endif strlen(const char *_string); strlen.c strlen #undef _INLINE #include <string.h> _CODE_ACCESS size_t strlen(cont char string) size_t (size_t)-1; const char string n++; while (*++s); return Using C/C++ Compiler 2-39 Using Inline Function Expansion 2.10.5 Inlining Restrictions There several restrictions what functions inlined both automatic inlining definition-controlled inlining. Functions with local static variables variable number arguments inlined, with exception functions decalred static inline. functions declared static inline, expansion occurs despite presence local static variables. addition, limit placed depth inlining recursive nonleaf functions. Furthermore, inlining should used small functions functions that called places (though compiler does enforce this). function disqualified from inlining Returns struct union struct union parameter volatile parameter variable length argument list Declares struct, union, enum type Contains static variable Contains volatile variable recursive Contains pragma large stack (too many local variables) 2-40 Interrupt Flexibility Options (-mi Option) 2.11 Interrupt Flexibility Options (-mi Option) 'C6000 architecture, interrupts cannot taken delay slots branch. some instances compiler generate code that cannot interrupted potentially large number cycles. given real-time system, there hard limit long interrupts disabled. -min option specifies interrupt threshold value threshold value specifies maximum number cycles that compiler disable interrupts. omitted, threshold compiler assumes that code never interrupted. Code Composer Studio, specify that code never interrupted, must enter Interrupt Threshold field Build Options dialog Compiler tab, Advanced category. will -mii appear Options field. Interrupts only disabled around software pipelined loops. When using -min option, compiler analyzes loop structure loop counter determine maximum number cycles will take execute loop. determine that maximum number cycles less than threshold value, then compiler will disable interrupts around software pipelined loop. Otherwise, compiler makes loop interruptible, which most cases degrades performance loop. -min option does comprehend effects memory system. When determining maximum number execution cycles loop, compiler does compute effects using slow off-chip memory memory bank conflicts. recommended that conservative threshold value used adjust effects memory system. section 7.7.7, FUNC_INTERRUPT_THRESHOLD Pragma, page 7-23 TMS320C6000 Programmer's Guide more information. Note: Library Files Built With Option library files provided with compiler built with interrupt flexibility option. Please refer readme file library files were built your release. Chapter Library-Build Utility, build your library files with interrupt flexibility option. Using C/C++ Compiler 2-41 Using Interlist Utility 2.12 Using Interlist Utility compiler tools include utility that interlists C/C++ source statements into assembly language output compiler. interlist utility enables inspect assembly code generated each statement. interlist utility behaves differently, depending whether optimizer used, depending which options specify. easiest invoke interlist utility option. compile interlist utility program called function.c, enter: cl6x function option prevents shell from deleting interlisted assembly language output file. output assembly file, function.asm, assembled normally. When invoke interlist utility without optimizer, interlist utility runs separate pass between code generator assembler. reads both assembly C/C++ source files, merges them, writes C/C++ statements into assembly file comments. Using option cause performance and/or code size degradation. Example shows typical interlisted assembly file. 2-42 Using Interlist Utility Example 2-3. Interlisted Assembly Language File _main: B3,*SP--(12) A10,*+SP(8) printf("Hello, world\n"); _printf MVKL SL1+0,A0 MVKH SL1+0,A0 MVKL RL0,B3 A0,*+SP(4) MVKH RL0,B3 RL0: CALL OCCURS return ZERO A10,A4 *+SP(8),A10 *++SP(12),B3 BRANCH OCCURS more information about using interlist utility with optimizer, section 3.11, Using Interlist Utility With Optimizer, page 3-29. Using C/C++ Compiler 2-43 Chapter Optimizing Your Code compiler tools perform many optimizations that improve execution speed reduce size programs performing tasks such simplifying loops, software pipelining, rearranging statements expressions, allocating variables into registers. This chapter describes invoke different levels optimization describes which optimizations performed each level. This chapter also describes interlist utility when performing optimization profile debug optimized code. Topic Page Invoking Optimization Optimizing Software Pipelining Redundant Loops 3-16 Reducing Code Size (-ms Option) 3-17 Performing File-Level Optimization (-o3 Option) 3-18 Performing Program-Level Optimization (-pm Options) 3-20 Indicating Whether Certain Aliasing Techniques Used 3-24 Prevent Reordering Associative Floating-Point Operations 3-27 Caution With Statements Optimized Code 3-27 3.10 Automatic Inline Expansion (-oi Option) 3-28 3.11 Using Interlist Utility With Optimizer 3-29 3.12 Debugging Profiling Optimized Code 3-32 3.13 What Kind Optimization Being Performed? 3-34 Optimizing Your Code Invoking Optimization Invoking Optimization C/C++ compiler able perform various optimizations. High-level optimizations performed optimizer low-level, target-specific optimizations occur code generator. high-level optimizer runs separate pass between parser code generator. Figure illustrates execution flow compiler with stand-alone optimizer code generator. Figure 3-1. Compiling C/C++ Program With Optimizer C/C++ source file Parser Optimizer Code generator file .opt file .asm file easiest invoke optimization cl6x shell program, specifying option cl6x command line. denotes level optimization which controls type degree optimization. Performs control-flow-graph simplification Allocates variables registers Performs loop rotation Eliminates unused code Simplifies expressions statements Expands calls functions declared inline Performs optimizations, plus: Performs local copy/constant propagation Removes unused assignments Eliminates local common expressions Invoking Optimization Performs optimizations, plus: Performs software pipelining (see section page 3-4) Performs loop optimizations Eliminates global common subexpressions Eliminates global unused assignments Converts array references loops incremented pointer form Performs loop unrolling optimizer uses default without optimization level. Performs optimizations, plus: Removes functions that never called Simplifies functions with return values that never used Inlines calls small functions Reorders function declarations that attributes called functions known when caller optimized Propagates arguments into function bodies when calls pass same value same argument position Identifies file-level variable characteristics -o3, section 3.5, Using Option, page 3-18 more information. addition these optimizations, there some optimizations that performed regardless optimization level. These optimizations cannot turned off. Note: Lower Optimization Level Control Code Size When trying reduce code size, lower level optimization. Instead, option control code size/performance tradeoff. Higher levels combined with high levels generally result smallest code size. more information, section 3.4, Reducing Code Size (-ms Option), page 3-17. Note: Option Applies Assembly Optimizer option should also used with assembly optimizer. Although assembly optimizer does perform optimizations described here, optimizations such software pipelining loop unrolling require option specified. Optimizing Your Code Optimizing Software Pipelining Optimizing Software Pipelining Software pipelining technique used schedule instructions from loop that multiple iterations loop execute parallel. compiler always attempts software pipeline. general, code size performance better when option. (See section 3.1, Invoking Optimization.) should also option reduce code size. Figure illustrates software pipelined loop. stages loop represented this figure, maximum five iterations loop execute time. shaded area represents loop kernel. loop kernel, five stages execute parallel. area above kernel known pipelined loop prolog, area below kernel known pipelined loop epilog. Figure 3-2. Software-Pipelined Loop Pipelined-loop epilog Kernel Pipelined-loop prolog assembly optimizer also software pipelines loops. more information about assembly optimizer, Chapter more information about software-pipelining, TMS320C6000 Programmer's Guide. Optimizing Software Pipelining 3.2.1 Turn Software Pipelining (-mu Option) optimization levels -o3, compiler attempts software pipeline your loops. might want your loops software-pipelined debugging reasons. Software-pipelined loops sometimes difficult debug because code presented serially. option affects both compiled C/C++ code assembly optimized code. Note: Software Pipelining Significantly Increase Code Size reduce code size, -ms2 -ms3 option non-performance critical code, rather than option. These code size options only disable software pipelining, they enable code size reduction optimizations. 3.2.2 Software Pipelining Information compiler embeds software pipelined loop information .asm file. This information used optimize C/C++ code linear assembly code. software pipelining information appears comment .asm file before loop assembly optimizer information displayed tool running. Example illustrates information that generated each loop. Optimizing Your Code Optimizing Software Pipelining Example 3-1. Software Pipelining Information SOFTWARE PIPELINE INFORMATION Known Minimum Trip Count Known Maximum Trip Count Known Trip Count Factor Loop Carried Dependency Bound(^) Unpartitioned Resource Bound Partitioned Resource Bound(*) Resource Partition: A-side B-side units units units units cross paths address paths Long read paths Long write paths Logical (.LS) Addition (.LSD) Bound(.L .LS) Bound(.L .LSD) unit) unit) Searching software pipeline schedule Register live long find schedule Schedule found with iterations parallel done Epilog entirely removed Collapsed epilog stages Prolog removed Collapsed prolog stages Minimum required memory bytes Minimum safe trip count Optimizing Software Pipelining terms defined below appear software pipelining information. more information each term, TMS320C6000 Programmer's Guide. Loop unroll factor. number times loop unrolled specifi- cally increase performance based resource bound constraint software pipelined loop. Known minimum trip count. minimum number times loop will executed. Known maximum trip count. maximum number times loop will executed. Known trip count factor. Factor that would always evenly divide loops trip count. This information used possibly unroll loop. Loop label. label specified loop linear assembly input file. This field present C/C++ code. Loop carried dependency bound. distance largest loop carry path. loop carry path occurs when iteration loop writes value that must read future iteration. Instructions that part loop carry bound marked with symbol. Iteration interval (ii). number cycles between initiation successive iterations loop. smaller iteration interval, fewer cycles takes execute loop. Resource bound. most used resource constrains minimum itera- tion interval. example, four instructions require unit, they require least cycles execute instructions/2 parallel units). Unpartitioned resource bound. best possible resource bound val- before instructions loop partitioned particular side. Partitioned resource bound (*). resource bound values after instructions partitioned. Resource partition. This table summarizes instructions have been partitioned. This information used help assign functional units when writing linear assembly. Each table entry values A-side B-side registers. asterisk used mark those entries that determine resource bound value. table entries represent following terms: units total number instructions that require units. units total number instructions that require units. Optimizing Your Code Optimizing Software Pipelining units total number instructions that require units. units total number instructions that require units. cross paths total number cross paths. address paths total number address paths. Long read path total number long read port paths. Long write path total number long write port paths. Logical (.LS) total number instructions that either unit. Addition (.LSD) total number instructions that either unit Bound(.L .LS) resource bound value determined number instructions that units. calculated with following formula: Bound(.L ceil((.L .LS) Bound(.L .LSD) resource bound value determined number instructions that unit. calculated with following formula: Bound(.L .LSD) ceil((.L .LSD) Minimum required memory pad. number bytes that read speculative execution enabled. section 3.2.3, Collapsing Prologs Epilogs Improved Performance Code Size, page 3-13, more information. Optimizing Software Pipelining 3.2.2.1 Loop Disqualified Software Pipelining Messages following messages appear loop completely disqualified software pipelining: loop structure. This error very rare stem from follow- ing: statement inserted code innerloop Parallel instructions being used input Linear Assembly Optimizer Complex control flow such GOTO statements breaks Loop contains call. Sometimes compiler able inline function call that loop. Because compiler could inline function call, loop could software pipelined. many instructions. There many instructions loop software pipeline. Software pipelining disabled. Software pipelining been disabled command-line option. Pipelining turned when using option, using option, using -ms2 -ms3 option. Uninitialized trip counter. trip counter have been initial value. Suppressed prevent code expansion. Software pipelining suppressed because -ms1 option. When -ms1 option used, software pipelining disabled less promising cases reduce code size. enable pipelining, -ms0 omit option altogether. Loop carried dependency bound large. loop complex loop control, according recommendations section 3.2.3.2, Selecting Best Threshold Value, page 3-14. Cannot identify trip counter. loop trip counter could identified used incorrectly loop body. Optimizing Your Code Optimizing Software Pipelining 3.2.2.2 Pipeline Failure Messages following messages appear when compiler assembly optimizer processing software pipeline fails: Address increment large. address register's offset must justed because offset range 'C6000's offset addressing mode. must minimize address register offsets. Cannot allocate machine registers. software pipeline schedule found, cannot allocate machine registers schedule. must simplify loop. register usage schedule found given displayed. This information used when writing linear assembly balance register pressure both sides register file. example: Cannot allocate machine registers Regs Live Always (A/B-side) Regs Live 20/14 Condo Regs Live Regs Live Always. number values that must assigned register duration whole loop body. This means that these values must always allocated registers given schedule found loop. Regs Live. Maximum number values live given cycle loop that must allocated register. This indicates maximum number registers required schedule found. Cond Regs Live. Maximum number registers live given cycle loop kernel that must allocated condition register. Cycle count high profitable. With schedule that com- piler found loop, more efficient non-software-pipelined version. find schedule. compiler unable find schedule software pipeline given (iteration interval). should simplify loop and/or eliminate loop carried dependencies. Iterations parallel minimum maximum trip count. software pipeline schedule found, schedule more iterations parallel than minimum maximum loop trip count. must enable redundant loops communicate trip information. Speculative threshold exceeded. would necessary speculatively load beyond threshold currently specified option. must increase threshold recommended software-pipeline feedback located assembly file. 3-10 Optimizing Software Pipelining Register live long. register must have value that exists live) more than cycles. insert instructions split register lifetimes that long. assembly optimizer being used, file line numbers instructions that define registers that live long listed after this failure message. Register live long |10| |17| This means that instruction that defines register value line instruction that uses register value line file. many predicates live side. 'C6000 predicate, conditional, registers available with conditional instructions. There predicate registers 'C6200 'C6700, predicate registers 'C6400. There three side three side. Sometimes particular partition schedule combination requires more than these available registers. Schedule found with iterations parallel. software pipeline schedule found with iterations executing parallel. many reads register. same register read maxi- times cycle with 'C6200 'C6700 core. 'C6400 core read same register number times cycle. Trip variable used loop Can't adjust trip count. loop trip counter loop other than loop trip counter. Optimizing Your Code 3-11 Optimizing Software Pipelining 3.2.2.3 Investigative Feedback following messages appear when compiler assembly optimizer detects that performance improved with software pipeline: Loop carried dependency bound much larger than unpartitioned resource bound. There potential memory alias disambiguation problem. This means that there pointers that point same location, thus, compiler must assume they might. This cause dependency (often between load pointer store another) that does really exist. software pipelined loops, this greatly degrade performance. loops generated, software pipelined. trip count low, illegal execute software pipelined version loop. this case, compiler could guarantee that minimum trip count would high enough always safely execute pipelined version. Hence, generated non-pipelined version well. Code generated, that time, appropriate version loop will executed. Uneven resources. number resources particular opera- tion odd, unrolling loop beneficial. loop requires multiplies, then minimum iteration interval cycles required execute this. loop unrolled, multiplies could evenly partitioned across side, having minimum cycles, giving improved performance. Larger outer loop overhead nested loop. cases where inner loop count nested loop relatively small, time execute outer loop start become large percentage total execution time. cases where this significantly degrades overall loop performance, unrolling inner loop desired. There memory bank conflicts. cases where compiler gener- ates memory accesses cycle those accesses either bytes apart 'C620x device, bytes apart 'C670x device, bytes apart 'C640x device, both accesses reside within same memory block, memory bank stall will occur. Memory bank conflicts completely avoided either placing accesses different memory blocks writing linear assembly using .mptr directive control memory banks. address paths resource bound. address paths defined num- memory accesses that must sent address each loop iteration. these resource bound loop, often possible reduce number accesses performing word accesses (LDW/STW) short accesses being performed. 3-12 Optimizing Software Pipelining 3.2.3 Collapsing Prologs Epilogs Improved Performance Code Size When loop software pipelined, prolog epilog generally required. prolog used pipe loop epilog used pipe down loop. general, loop must execute minimum number iterations before software-pipelined version safely executed. minimum known trip count small, either redundant loop added software pipelining disabled. Collapsing prolog epilog loop reduce minimum trip count necessary safely execute pipelined loop. Collapsing also substantially reduce code size. Some this code size growth redundant loop. remainder prolog epilog. prolog epilog software-pipelined loop consists stages length where number iterations that executed parallel during steady state cycle time pipelined loop body. During prolog epilog collapsing compiler tries collapse many stages possible. However, overcollapsing have negative performance impact. Thus, default, compiler attempts collapse many stages possible without sacrificing performance. When -ms0/-ms1 options invoked, compiler increasingly favors code size over performance. 3.2.3.1 Speculative Execution When prologs epilogs collapsed, instructions might speculatively executed, thereby causing loads addresses beyond either range explicitly read within loop. default, compiler cannot speculate loads because this could cause illegal memory location read. Sometimes, compiler predicate these loads prevent over execution. However, this increase register pressure might decrease total amount collapsing which performed. When -mhn option used, speculative threshold increased from default When threshold compiler allow load speculatively executed memory location reads will more than bytes before after some location explicitly read within loop. Code Composer Studio, must enter Speculative Execution field Build Options dialog Compiler tab, Advanced category. will -mhh appear Options field. Collapsing usually reduce minimum safe trip count. minimum known trip count less than minimum safe trip count, redundant loop required. Otherwise, pipelining must supressed. Both these values found comment block preceding software pipelined loop. Optimizing Your Code 3-13 Optimizing Software Pipelining Known Minimum Trip Count Minimum safe trip count minimum safe trip count greater than minimum known trip count, highly recommended, only code size, performance well. When using -mh, must ensure that potentially speculated loads will cause illegal reads. This done padding data sections and/or stack, needed, required memory both directions. required memory given software-pipelined loop also provided comment block that loop. Minimum required memory bytes 3.2.3.2 Selecting Best Threshold Value When loop software pipelined, comment block preceding loop provides following information: Required memory this loop minimum value needed achieve this software pipeline schedule level collapsing Suggestion larger value which might allow additional col- lapsing This information shows comment block follows: -mh14 Minimum required memory bytes Minimum threshold value -mh7 further improvement this loop, option safety, example loop requires that array data referenced within this loop preceded followed least bytes. This consist other program data. will modified. many cases, threshold value (namely, minimum value argument that needed achieve particular schedule level collapsing) same pad. However, when not, comment block will also include minimum threshold value. case this loop, threshold value must least achieve this level collapsing. Another interesting question that arises whether there larger threshold value which would facilitate additional collapsing? there this information will also provided. example, above comment block, threshold value might facilitate further collapsing. 3-14 Optimizing Software Pipelining able help compiler avoid producing redundant loops with (see section page 3-20) MUST_ITERATE pragma (see section 7.7.14 page 7-27.) Note: Turning Redundant Loops Specifying option turns redundant loops. 3.2.4 Selecting Target Version (-mv Option) Select target version using last four digits TMS320C6000 part number. This selection controls target-specific instructions alignment, such -mv6701 -mv6412. Alternatively, also specify family part, example, -mv6400 -mv6700. this option used, compiler generates code 'C6200 parts. option specified, code generated will 'C6000 parts; however, compiler does take advantage target-specific instructions alignment. Optimizing Your Code 3-15 Redundant Loops Redundant Loops Every loop iterates some number times before loop terminates. number iterations called trip count. variable used count each iteration trip counter. When trip counter reaches limit equal trip count, loop terminates. 'C6000 tools trip count determine whether loop pipelined. structure software pipelined loop requires execution minimum number loop iterations minimum trip count) order fill prime pipeline. minimum trip count software pipelined loop determined number iterations executing parallel. Figure page 3-4, minimum trip count five. following example instructions software pipeline, minimum trip count this single-cycle software pipelined loop three: Three iterations parallel minimum trip count When 'C6000 tools cannot determine trip count loop, then default loops control logic generated. first loop pipelined, executes run-time trip count less than loop's minimum trip count. second loop software pipelined loop, executes when run-time trip count greater than equal minimum trip count. given time, loops redundant loop. foo(N) trip count (i=0; i++) trip counter After finding software pipeline loop, compiler transforms foo( below, assuming minimum trip count loop versions loop would generated following comparison would used determine which version should executed: foo(N) (i=0; else (i=0; foo(50); Execute foo(2); Execute 3-16 i++) Unpipelined version i++) Pipelined version software pipelined loop loop (unpipelined)*/ Reducing Code Size (-ms Option) able help compiler avoid producing redundant loops with (see section page 3-20) MUST_ITERATE pragma (see section 7.7.14 page 7-27). Note: Turning Redundant Loops Specifying option turns redundant loops. Reducing Code Size (-ms Option) When using option, telling compiler optimize your code. higher value more effort compiler invests optimizing your code. However, might still need tell compiler what your optimization priorities are. default, when specified, compiler optimizes primarily performance. (Under lower optimization levels, priorities compilation time debugging ease.) adjust priorities between performance code size using code size flag -msn. -ms0, -ms1, -ms2 -ms3 options increasingly favor code size over performance. recommended that code size flag used with most performance-critical code. Using -ms0 -ms1 recommended most performance-critical code. Using -ms2 -ms3 recommended seldomexecuted code. Either -ms2 -ms3 should used also need minimum code size. cases, generally recommended that code size flags combined with -o3. Note: Disabling Code-Size Optimizations Reducing Optimization Level reduce optimization and/or code size flags, disabling code-size optimizations sacrificing performance. Optimizing Your Code 3-17 Performing File-Level Optimization Option) Performing File-Level Optimization Option) option instructs compiler perform file-level optimization. option alone perform general file-level optimization, combine with other options perform more specific optimizations. options listed Table work with perform indicated optimization: Table 3-1. Options That With Have files that redeclare standard library functions Want create optimization information file Want compile multiple source files this option -oln -onn Page 3-18 3-19 3-20 Note: Lower Optimization Level Control Code Size When trying reduce code size, lower level optimization. fact, might increase code size when lowering level optimization. Instead, option control code size/performance tradeoff. more information, section 3.4, Reducing Code Size (-ms Option), page 3-17. 3.5.1 Controlling File-Level Optimization (-oln Option) When invoke optimizer with option, some optimizations known properties standard library functions. your file redeclares these standard library functions, these optimizations become ineffective. (lowercase option controls file-level optimizations. number following denotes level Table select appropriate level append option. Table 3-2. Selecting Level Option your source file. Declares function with same name standard library function Contains does alter functions declared standard library Does alter standard library functions, used -ol0 -ol1 option command file environment variable. -ol2 option restores default behavior optimizer. this option -ol0 -ol1 -ol2 3-18 Performing File-Level Optimization Option) 3.5.2 Creating Optimization Information File (-onn Option) When invoke optimizer with option, option create optimization information file that read. number following denotes level resulting file .nfo extension. Table select appropriate level append option. Table 3-3. Selecting Level Option you. want produce information file, used -on1 -on2 option command file environment variable. -on0 option restores default behavior optimizer. Want produce optimization information file Want produce verbose optimization information file this option -on0 -on1 -on2 Optimizing Your Code 3-19 Performing Program-Level Optimization (-pm Options) Performing Program-Level Optimization (-pm Options) specify program-level optimization using option with option. With program-level optimization, your source files compiled into intermediate file called module. module moves optimization code generation passes compiler. Because compiler entire program, performs several optimizations that rarely applied during file-level optimization: particular argument function always same value, com- piler replaces argument with value passes value instead argument. return value function never used, compiler deletes return code function. function called, directly indirectly, compiler removes function. which program-level optimizations compiler applying, -on2 option generate information file. section 3.5.2, Creating Optimization Information File (-onn Option), page 3-19 more information. 3.6.1 Controlling Program-Level Optimization (-opn Option) control program-level optimization, which invoke with -o3, using option. Specifically, option indicates functions other modules call module's external functions modify module's external variables. number following indicates level module that allowing called modified. option combines this information with file-level analysis decide whether treat this module's external function variable declarations they been declared static. Table select appropriate level append option. Table 3-4. Selecting Level Option your module functions that called from other modules global variables that modified other modules Does have functions that called other modules global variables that modified other modules Does have functions that called other modules global variables that modified other modules functions t Other recent searchesW383SRDT - W383SRDT W383SRDT Datasheet ST72324BLxx-Auto - ST72324BLxx-Auto ST72324BLxx-Auto Datasheet SSM3K01F - SSM3K01F SSM3K01F Datasheet PI3L500 - PI3L500 PI3L500 Datasheet PI216MC-DR - PI216MC-DR PI216MC-DR Datasheet PI209M-A6 - PI209M-A6 PI209M-A6 Datasheet MSC23136D - MSC23136D MSC23136D Datasheet DL-xxBS10 - DL-xxBS10 DL-xxBS10 Datasheet DS10 - DS10 DS10 Datasheet MAX764 - MAX764 MAX764 Datasheet MAX765CSA - MAX765CSA MAX765CSA Datasheet MAX766 - MAX766 MAX766 Datasheet IDT74LVC109A - IDT74LVC109A IDT74LVC109A Datasheet DI9405 - DI9405 DI9405 Datasheet
Privacy Policy | Disclaimer |