TMS320C6000 Optimizing Compiler V8.2.X User's Guide (Rev. B)

Total Page:16

File Type:pdf, Size:1020Kb

TMS320C6000 Optimizing Compiler V8.2.X User's Guide (Rev. B) TMS320C6000 Optimizing Compiler v8.2.x User's Guide Literature Number: SPRUI04B May 2017 Contents Preface....................................................................................................................................... 11 1 Introduction to the Software Development Tools.................................................................... 14 1.1 Software Development Tools Overview ................................................................................. 15 1.2 Compiler Interface.......................................................................................................... 16 1.3 ANSI/ISO Standard ........................................................................................................ 16 1.4 Output Files ................................................................................................................. 17 1.5 Utilities ....................................................................................................................... 17 2 Getting Started with the Code Generation Tools .................................................................... 18 2.1 How Code Composer Studio Projects Use the Compiler ............................................................. 18 2.2 Compiling from the Command Line ..................................................................................... 19 3 Using the C/C++ Compiler ................................................................................................... 20 3.1 About the Compiler......................................................................................................... 21 3.2 Invoking the C/C++ Compiler ............................................................................................. 21 3.3 Changing the Compiler's Behavior with Options ....................................................................... 22 3.3.1 Linker Options ..................................................................................................... 29 3.3.2 Frequently Used Options......................................................................................... 31 3.3.3 Miscellaneous Useful Options ................................................................................... 33 3.3.4 Run-Time Model Options......................................................................................... 35 3.3.5 Selecting Target CPU Version (--silicon_version Option).................................................... 36 3.3.6 Symbolic Debugging and Profiling Options .................................................................... 36 3.3.7 Specifying Filenames ............................................................................................. 37 3.3.8 Changing How the Compiler Interprets Filenames ........................................................... 37 3.3.9 Changing How the Compiler Processes C Files .............................................................. 38 3.3.10 Changing How the Compiler Interprets and Names Extensions ........................................... 38 3.3.11 Specifying Directories............................................................................................ 38 3.3.12 Assembler Options............................................................................................... 39 3.3.13 Dynamic Linking.................................................................................................. 40 3.4 Controlling the Compiler Through Environment Variables............................................................ 41 3.4.1 Setting Default Compiler Options (C6X_C_OPTION) ........................................................ 41 3.4.2 Naming One or More Alternate Directories (C6X_C_DIR)................................................... 42 3.5 Controlling the Preprocessor ............................................................................................. 43 3.5.1 Predefined Macro Names ........................................................................................ 43 3.5.2 The Search Path for #include Files ............................................................................. 44 3.5.3 Support for the #warning and #warn Directives ............................................................... 45 3.5.4 Generating a Preprocessed Listing File (--preproc_only Option) ........................................... 45 3.5.5 Continuing Compilation After Preprocessing (--preproc_with_compile Option) ........................... 45 3.5.6 Generating a Preprocessed Listing File with Comments (--preproc_with_comment Option) ........... 45 3.5.7 Generating Preprocessed Listing with Line-Control Details (--preproc_with_line Option) ............... 46 3.5.8 Generating Preprocessed Output for a Make Utility (--preproc_dependency Option) ................... 46 3.5.9 Generating a List of Files Included with #include (--preproc_includes Option) ........................... 46 3.5.10 Generating a List of Macros in a File (--preproc_macros Option) ......................................... 46 3.6 Passing Arguments to main()............................................................................................. 46 3.7 Understanding Diagnostic Messages.................................................................................... 47 3.7.1 Controlling Diagnostic Messages ............................................................................... 48 3.7.2 How You Can Use Diagnostic Suppression Options ......................................................... 49 2 Contents SPRUI04B–May 2017 Submit Documentation Feedback Copyright © 2017, Texas Instruments Incorporated www.ti.com 3.8 Other Messages ............................................................................................................ 50 3.9 Generating Cross-Reference Listing Information (--gen_cross_reference Option)................................ 50 3.10 Generating a Raw Listing File (--gen_preprocessor_listing Option)................................................. 50 3.11 Using Inline Function Expansion ......................................................................................... 52 3.11.1 Inlining Intrinsic Operators ...................................................................................... 53 3.11.2 Automatic Inlining ................................................................................................ 53 3.11.3 Unguarded Definition-Controlled Inlining...................................................................... 53 3.11.4 Guarded Inlining and the _INLINE Preprocessor Symbol .................................................. 53 3.11.5 Inlining Restrictions .............................................................................................. 55 3.12 Interrupt Flexibility Options (--interrupt_threshold Option) ............................................................ 56 3.13 Using Interlist ............................................................................................................... 57 3.14 Generating and Using Performance Advice ............................................................................ 58 3.15 About the Application Binary Interface .................................................................................. 58 3.16 Enabling Entry Hook and Exit Hook Functions......................................................................... 59 4 Optimizing Your Code......................................................................................................... 60 4.1 Invoking Optimization ...................................................................................................... 61 4.2 Optimizing Software Pipelining ........................................................................................... 62 4.2.1 Turn Off Software Pipelining (--disable_software_pipelining Option)....................................... 63 4.2.2 Software Pipelining Information ................................................................................. 63 4.2.3 Collapsing Prologs and Epilogs for Improved Performance and Code Size .............................. 68 4.3 Redundant Loops .......................................................................................................... 69 4.4 Utilizing the Loop Buffer Using SPLOOP ............................................................................... 70 4.5 Reducing Code Size (--opt_for_space (or -ms) Option) .............................................................. 71 4.6 Performing File-Level Optimization (--opt_level=3 option)............................................................ 71 4.6.1 Creating an Optimization Information File (--gen_opt_info Option)......................................... 71 4.7 Program-Level Optimization (--program_level_compile and --opt_level=3 options)............................... 72 4.7.1 Controlling Program-Level Optimization (--call_assumptions Option)...................................... 72 4.7.2 Optimization Considerations When Mixing C/C++ and Assembly .......................................... 73 4.8 Using Feedback Directed Optimization.................................................................................. 75 4.8.1 Feedback Directed Optimization ................................................................................ 75 4.8.2 Profile Data Decoder.............................................................................................. 77 4.8.3 Feedback Directed Optimization API ..........................................................................
Recommended publications
  • A Deep Dive Into the Interprocedural Optimization Infrastructure
    Stes Bais [email protected] Kut el [email protected] Shi Oku [email protected] A Deep Dive into the Luf Cen Interprocedural [email protected] Hid Ue Optimization Infrastructure [email protected] Johs Dor [email protected] Outline ● What is IPO? Why is it? ● Introduction of IPO passes in LLVM ● Inlining ● Attributor What is IPO? What is IPO? ● Pass Kind in LLVM ○ Immutable pass Intraprocedural ○ Loop pass ○ Function pass ○ Call graph SCC pass ○ Module pass Interprocedural IPO considers more than one function at a time Call Graph ● Node : functions ● Edge : from caller to callee A void A() { B(); C(); } void B() { C(); } void C() { ... B C } Call Graph SCC ● SCC stands for “Strongly Connected Component” A D G H I B C E F Call Graph SCC ● SCC stands for “Strongly Connected Component” A D G H I B C E F Passes In LLVM IPO passes in LLVM ● Where ○ Almost all IPO passes are under llvm/lib/Transforms/IPO Categorization of IPO passes ● Inliner ○ AlwaysInliner, Inliner, InlineAdvisor, ... ● Propagation between caller and callee ○ Attributor, IP-SCCP, InferFunctionAttrs, ArgumentPromotion, DeadArgumentElimination, ... ● Linkage and Globals ○ GlobalDCE, GlobalOpt, GlobalSplit, ConstantMerge, ... ● Others ○ MergeFunction, OpenMPOpt, HotColdSplitting, Devirtualization... 13 Why is IPO? ● Inliner ○ Specialize the function with call site arguments ○ Expose local optimization opportunities ○ Save jumps, register stores/loads (calling convention) ○ Improve instruction locality ● Propagation between caller and callee ○ Other passes would benefit from the propagated information ● Linkage
    [Show full text]
  • The LLVM Instruction Set and Compilation Strategy
    The LLVM Instruction Set and Compilation Strategy Chris Lattner Vikram Adve University of Illinois at Urbana-Champaign lattner,vadve ¡ @cs.uiuc.edu Abstract This document introduces the LLVM compiler infrastructure and instruction set, a simple approach that enables sophisticated code transformations at link time, runtime, and in the field. It is a pragmatic approach to compilation, interfering with programmers and tools as little as possible, while still retaining extensive high-level information from source-level compilers for later stages of an application’s lifetime. We describe the LLVM instruction set, the design of the LLVM system, and some of its key components. 1 Introduction Modern programming languages and software practices aim to support more reliable, flexible, and powerful software applications, increase programmer productivity, and provide higher level semantic information to the compiler. Un- fortunately, traditional approaches to compilation either fail to extract sufficient performance from the program (by not using interprocedural analysis or profile information) or interfere with the build process substantially (by requiring build scripts to be modified for either profiling or interprocedural optimization). Furthermore, they do not support optimization either at runtime or after an application has been installed at an end-user’s site, when the most relevant information about actual usage patterns would be available. The LLVM Compilation Strategy is designed to enable effective multi-stage optimization (at compile-time, link-time, runtime, and offline) and more effective profile-driven optimization, and to do so without changes to the traditional build process or programmer intervention. LLVM (Low Level Virtual Machine) is a compilation strategy that uses a low-level virtual instruction set with rich type information as a common code representation for all phases of compilation.
    [Show full text]
  • Undefined Behaviour in the C Language
    FAKULTA INFORMATIKY, MASARYKOVA UNIVERZITA Undefined Behaviour in the C Language BAKALÁŘSKÁ PRÁCE Tobiáš Kamenický Brno, květen 2015 Declaration Hereby I declare, that this paper is my original authorial work, which I have worked out by my own. All sources, references, and literature used or excerpted during elaboration of this work are properly cited and listed in complete reference to the due source. Vedoucí práce: RNDr. Adam Rambousek ii Acknowledgements I am very grateful to my supervisor Miroslav Franc for his guidance, invaluable help and feedback throughout the work on this thesis. iii Summary This bachelor’s thesis deals with the concept of undefined behavior and its aspects. It explains some specific undefined behaviors extracted from the C standard and provides each with a detailed description from the view of a programmer and a tester. It summarizes the possibilities to prevent and to test these undefined behaviors. To achieve that, some compilers and tools are introduced and further described. The thesis contains a set of example programs to ease the understanding of the discussed undefined behaviors. Keywords undefined behavior, C, testing, detection, secure coding, analysis tools, standard, programming language iv Table of Contents Declaration ................................................................................................................................ ii Acknowledgements .................................................................................................................. iii Summary .................................................................................................................................
    [Show full text]
  • Handout – Dataflow Optimizations Assignment
    Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout – Dataflow Optimizations Assignment Tuesday, Mar 19 DUE: Thursday, Apr 4, 9:00 pm For this part of the project, you will add dataflow optimizations to your compiler. At the very least, you must implement global common subexpression elimination. The other optimizations listed below are optional. You may also wait until the next project to implement them if you are going to; there is no requirement to implement other dataflow optimizations in this project. We list them here as suggestions since past winners of the compiler derby typically implement each of these optimizations in some form. You are free to implement any other optimizations you wish. Note that you will be implementing register allocation for the next project, so you don’t need to concern yourself with it now. Global CSE (Common Subexpression Elimination): Identification and elimination of redun- dant expressions using the algorithm described in lecture (based on available-expression anal- ysis). See §8.3 and §13.1 of the Whale book, §10.6 and §10.7 in the Dragon book, and §17.2 in the Tiger book. Global Constant Propagation and Folding: Compile-time interpretation of expressions whose operands are compile time constants. See the algorithm described in §12.1 of the Whale book. Global Copy Propagation: Given a “copy” assignment like x = y , replace uses of x by y when legal (the use must be reached by only this def, and there must be no modification of y on any path from the def to the use).
    [Show full text]
  • ACCU 2015 “New” Features in C
    "New" Features in C ACCU 2015 “New” Features in C Dan Saks Saks & Associates www.dansaks.com 1 Abstract The first international standard for the C programming language was C90. Since then, two newer standards have been published, C99 and C11. C99 introduced a significant number of new features. C11 introduced a few more, some of which have been available in compilers for some time. Curiously, many of these added features don’t seem to have caught on. Many C programmers still program in C90. This session explains many of these “new” features, including declarations in for-statements, typedef redefinitions, inline functions, complex arithmetic, extended integer types, variable- length arrays, flexible array members, compound literals, designated initializers, restricted pointers, type-qualified array parameters, anonymous structures and unions, alignment support, non-returning functions, and static assertions. 2 Copyright © 2015 by Daniel Saks 1 "New" Features in C About Dan Saks Dan Saks is the president of Saks & Associates, which offers training and consulting in C and C++ and their use in developing embedded systems. Dan has written columns for numerous print publications including The C/C++ Users Journal , The C++ Report , Software Development , and Embedded Systems Design . He currently writes the online “Programming Pointers” column for embedded.com . With Thomas Plum, he wrote C++ Programming Guidelines , which won a 1992 Computer Language Magazine Productivity Award . He has also been a Microsoft MVP. Dan has taught thousands of programmers around the world. He has presented at conferences such as Software Development and Embedded Systems , and served on the advisory boards for those conferences.
    [Show full text]
  • Analysis of Program Optimization Possibilities and Further Development
    View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by Elsevier - Publisher Connector Theoretical Computer Science 90 (1991) 17-36 17 Elsevier Analysis of program optimization possibilities and further development I.V. Pottosin Institute of Informatics Systems, Siberian Division of the USSR Acad. Sci., 630090 Novosibirsk, USSR 1. Introduction Program optimization has appeared in the framework of program compilation and includes special techniques and methods used in compiler construction to obtain a rather efficient object code. These techniques and methods constituted in the past and constitute now an essential part of the so called optimizing compilers whose goal is to produce an object code in run time, saving such computer resources as CPU time and memory. For contemporary supercomputers, the requirement of the proper use of hardware peculiarities is added. In our opinion, the existence of a sufficiently large number of optimizing compilers with real possibilities of producing “good” object code has evidently proved to be practically significant for program optimization. The methods and approaches that have accumulated in program optimization research seem to be no lesser valuable, since they may be successfully used in the general techniques of program construc- tion, i.e. in program synthesis, program transformation and at different steps of program development. At the same time, there has been criticism on program optimization and even doubts about its necessity. On the one hand, this viewpoint is based on blind faith in the new possibilities bf computers which will be so powerful that any necessity to worry about program efficiency will disappear.
    [Show full text]
  • Comparative Studies of Programming Languages; Course Lecture Notes
    Comparative Studies of Programming Languages, COMP6411 Lecture Notes, Revision 1.9 Joey Paquet Serguei A. Mokhov (Eds.) August 5, 2010 arXiv:1007.2123v6 [cs.PL] 4 Aug 2010 2 Preface Lecture notes for the Comparative Studies of Programming Languages course, COMP6411, taught at the Department of Computer Science and Software Engineering, Faculty of Engineering and Computer Science, Concordia University, Montreal, QC, Canada. These notes include a compiled book of primarily related articles from the Wikipedia, the Free Encyclopedia [24], as well as Comparative Programming Languages book [7] and other resources, including our own. The original notes were compiled by Dr. Paquet [14] 3 4 Contents 1 Brief History and Genealogy of Programming Languages 7 1.1 Introduction . 7 1.1.1 Subreferences . 7 1.2 History . 7 1.2.1 Pre-computer era . 7 1.2.2 Subreferences . 8 1.2.3 Early computer era . 8 1.2.4 Subreferences . 8 1.2.5 Modern/Structured programming languages . 9 1.3 References . 19 2 Programming Paradigms 21 2.1 Introduction . 21 2.2 History . 21 2.2.1 Low-level: binary, assembly . 21 2.2.2 Procedural programming . 22 2.2.3 Object-oriented programming . 23 2.2.4 Declarative programming . 27 3 Program Evaluation 33 3.1 Program analysis and translation phases . 33 3.1.1 Front end . 33 3.1.2 Back end . 34 3.2 Compilation vs. interpretation . 34 3.2.1 Compilation . 34 3.2.2 Interpretation . 36 3.2.3 Subreferences . 37 3.3 Type System . 38 3.3.1 Type checking . 38 3.4 Memory management .
    [Show full text]
  • Introduction Inline Expansion
    CSc 553 Principles of Compilation Introduction 29 : Optimization IV Department of Computer Science University of Arizona [email protected] Copyright c 2011 Christian Collberg Inline Expansion I The most important and popular inter-procedural optimization is inline expansion, that is replacing the call of a procedure Inline Expansion with the procedure’s body. Why would you want to perform inlining? There are several reasons: 1 There are a number of things that happen when a procedure call is made: 1 evaluate the arguments of the call, 2 push the arguments onto the stack or move them to argument transfer registers, 3 save registers that contain live values and that might be trashed by the called routine, 4 make the jump to the called routine, Inline Expansion II Inline Expansion III 1 continued.. 3 5 make the jump to the called routine, ... This is the result of programming with abstract data types. 6 set up an activation record, Hence, there is often very little opportunity for optimization. 7 execute the body of the called routine, However, when inlining is performed on a sequence of 8 return back to the callee, possibly returning a result, procedure calls, the code from the bodies of several procedures 9 deallocate the activation record. is combined, opening up a larger scope for optimization. 2 Many of these actions don’t have to be performed if we inline There are problems, of course. Obviously, in most cases the the callee in the caller, and hence much of the overhead size of the procedure call code will be less than the size of the associated with procedure calls is optimized away.
    [Show full text]
  • Code Compose Code Composer Studio
    Code Composer Studio Code Composer Studio Developer(s) Texas Instruments Initial release 1999; 20 years ago Stable release 8.1 (8.1.0.00011) / 13 June 2018 ; 9 months ago Operating system Windows, Linux and macOS Platform IA-32 and x86-64 Available in 1 languages Type Integrated Development Environment Website ti.com/ccstudio Code Composer Studio (CCStudio or CCS) is an integrated development environment (IDE) to develop applications for Texas Instruments (TI) embedded processors. Texas Instruments embedded processors include TMS320 DSPs, OMAP system-on-a-chip, DaVinci system- on-a-chip, Sitara applications processors, Hercules microcontrollers, Simplelink MCUs (MSP432 and Wireless connectivity[2]microcontrollers), MSP430 and Tiva/Stellaris microcontrollers. It also enables debugging on several subsystems such as Ducati,[3] IVA Accelerator[4] and PRU-ICSS.[5] Code Composer Studio is primarily designed as for embedded project design and low-level (baremetal) JTAG based debugging. However, the latest releases are based on unmodified versions of the Eclipse open source IDE, which can be easily extended to include support for OS level application debug (Linux, Android, Windows Embedded) and open source compiler suites such as GCC. Early versions included a real time kernel called DSP/BIOS and its later inception SYS/BIOS. Currently, the successor to these tools, the TI-RTOS embedded tools ecosystem, is available for downloading as a free plugin to Code Composer Studio. History Originally Code Composer was a product from a company called GO DSP located in Toronto, Canada, and it was acquired by TI in 1997.[6] After the acquisition, Code Composer was bundled with a real-time kernel named DSP/BIOS[7] and its name was appended with the word Studio.
    [Show full text]
  • PGI Compilers
    USER'S GUIDE FOR X86-64 CPUS Version 2019 TABLE OF CONTENTS Preface............................................................................................................ xii Audience Description......................................................................................... xii Compatibility and Conformance to Standards............................................................xii Organization................................................................................................... xiii Hardware and Software Constraints.......................................................................xiv Conventions.................................................................................................... xiv Terms............................................................................................................ xv Related Publications.........................................................................................xvii Chapter 1. Getting Started.....................................................................................1 1.1. Overview................................................................................................... 1 1.2. Creating an Example..................................................................................... 2 1.3. Invoking the Command-level PGI Compilers......................................................... 2 1.3.1. Command-line Syntax...............................................................................2 1.3.2. Command-line Options............................................................................
    [Show full text]
  • Register Allocation and Method Inlining
    Combining Offline and Online Optimizations: Register Allocation and Method Inlining Hiroshi Yamauchi and Jan Vitek Department of Computer Sciences, Purdue University, {yamauchi,jv}@cs.purdue.edu Abstract. Fast dynamic compilers trade code quality for short com- pilation time in order to balance application performance and startup time. This paper investigates the interplay of two of the most effective optimizations, register allocation and method inlining for such compil- ers. We present a bytecode representation which supports offline global register allocation, is suitable for fast code generation and verification, and yet is backward compatible with standard Java bytecode. 1 Introduction Programming environments which support dynamic loading of platform-indep- endent code must provide supports for efficient execution and find a good balance between responsiveness (shorter delays due to compilation) and performance (optimized compilation). Thus, most commercial Java virtual machines (JVM) include several execution engines. Typically, there is an interpreter or a fast com- piler for initial executions of all code, and a profile-guided optimizing compiler for performance-critical code. Improving the quality of the code of a fast compiler has the following bene- fits. It raises the performance of short-running and medium length applications which exit before the expensive optimizing compiler fully kicks in. It also ben- efits long-running applications with improved startup performance and respon- siveness (due to less eager optimizing compilation). One way to achieve this is to shift some of the burden to an offline compiler. The main question is what optimizations are profitable when performed offline and are either guaranteed to be safe or can be easily validated by a fast compiler.
    [Show full text]
  • Software II: Principles of Programming Languages
    Software II: Principles of Programming Languages Lecture 6 – Data Types Some Basic Definitions • A data type defines a collection of data objects and a set of predefined operations on those objects • A descriptor is the collection of the attributes of a variable • An object represents an instance of a user- defined (abstract data) type • One design issue for all data types: What operations are defined and how are they specified? Primitive Data Types • Almost all programming languages provide a set of primitive data types • Primitive data types: Those not defined in terms of other data types • Some primitive data types are merely reflections of the hardware • Others require only a little non-hardware support for their implementation The Integer Data Type • Almost always an exact reflection of the hardware so the mapping is trivial • There may be as many as eight different integer types in a language • Java’s signed integer sizes: byte , short , int , long The Floating Point Data Type • Model real numbers, but only as approximations • Languages for scientific use support at least two floating-point types (e.g., float and double ; sometimes more • Usually exactly like the hardware, but not always • IEEE Floating-Point Standard 754 Complex Data Type • Some languages support a complex type, e.g., C99, Fortran, and Python • Each value consists of two floats, the real part and the imaginary part • Literal form real component – (in Fortran: (7, 3) imaginary – (in Python): (7 + 3j) component The Decimal Data Type • For business applications (money)
    [Show full text]