TMS320C6000 Optimizing Compiler V 6.1 User's Guide

Total Page:16

File Type:pdf, Size:1020Kb

TMS320C6000 Optimizing Compiler V 6.1 User's Guide TMS320C6000 Optimizing Compiler v 6.1 User's Guide Literature Number: SPRU187O May 2008 2 SPRU187O–May 2008 Submit Documentation Feedback Contents Preface.............................................................................................................................. 11 1 Introduction to the Software Development Tools .......................................................... 15 1.1 Software Development Tools Overview ................................................................................. 16 1.2 C/C++ Compiler Overview ................................................................................................ 17 1.2.1 ANSI/ISO Standard ............................................................................................... 17 1.2.2 Output Files ........................................................................................................ 18 1.2.3 Compiler Interface................................................................................................. 18 1.2.4 Utilities .............................................................................................................. 18 2 Using the C/C++ Compiler ......................................................................................... 19 2.1 About the Compiler......................................................................................................... 20 2.2 Invoking the C/C++ Compiler ............................................................................................. 20 2.3 Changing the Compiler's Behavior With Options ...................................................................... 21 2.3.1 Frequently Used Options......................................................................................... 27 2.3.2 Machine-Specific Options ........................................................................................ 30 2.3.3 Selecting Target CPU Version (--silicon_version Option).................................................... 31 2.3.4 Symbolic Debugging and Profiling Options .................................................................... 31 2.3.5 Specifying Filenames ............................................................................................. 32 2.3.6 Changing How the Compiler Interprets Filenames ........................................................... 33 2.3.7 Changing How the Compiler Processes C Files .............................................................. 33 2.3.8 Changing How the Compiler Interprets and Names Extensions ............................................ 33 2.3.9 Specifying Directories............................................................................................. 34 2.3.10 Assembler Options............................................................................................... 34 2.3.11 Deprecated Options.............................................................................................. 35 2.4 Controlling the Compiler Through Environment Variables............................................................ 36 2.4.1 Setting Default Compiler Options (C6X_C_OPTION) ........................................................ 36 2.4.2 Naming an Alternate Directory (C6X_C_DIR) ................................................................. 37 2.5 Precompiled Header Support ............................................................................................. 37 2.5.1 Automatic Precompiled Header ................................................................................. 37 2.5.2 Manual Precompiled Header .................................................................................... 38 2.5.3 Additional Precompiled Header Options ....................................................................... 38 2.6 Controlling the Preprocessor ............................................................................................. 38 2.6.1 Predefined Macro Names ........................................................................................ 38 2.6.2 The Search Path for #include Files ............................................................................. 39 2.6.3 Generating a Preprocessed Listing File (--preproc_only Option) ........................................... 40 2.6.4 Continuing Compilation After Preprocessing (--preproc_with_compile Option) ........................... 40 2.6.5 Generating a Preprocessed Listing File With Comments (--preproc_with_comments Option) ......... 40 2.6.6 Generating a Preprocessed Listing File With Line-Control Information (--preproc_with_line Option).. 41 2.6.7 Generating Preprocessed Output for a Make Utility (--preproc_dependency Option) ................... 41 2.6.8 Generating a List of Files Included With the #include Directive (--preproc_includes Option) ........... 41 2.6.9 Generating a List of Macros in a File (--preproc_macros Option) .......................................... 41 2.7 Understanding Diagnostic Messages.................................................................................... 41 SPRU187O–May 2008 Contents 3 Submit Documentation Feedback www.ti.com 2.7.1 Controlling Diagnostics ........................................................................................... 42 2.7.2 How You Can Use Diagnostic Suppression Options ......................................................... 43 2.8 Other Messages ............................................................................................................ 44 2.9 Generating Cross-Reference Listing Information (--gen_acp_xref Option)......................................... 44 2.10 Generating a Raw Listing File (--gen_acp_raw Option)............................................................... 45 2.11 Using Inline Function Expansion ......................................................................................... 46 2.11.1 Inlining Intrinsic Operators ...................................................................................... 46 2.11.2 Automatic Inlining ................................................................................................ 46 2.11.3 Unguarded Definition-Controlled Inlining...................................................................... 46 2.11.4 Guarded Inlining and the _INLINE Preprocessor Symbol .................................................. 47 2.11.5 Inlining Restrictions .............................................................................................. 48 2.12 Interrupt Flexibility Options (--interrupt_threshold Option) ............................................................ 49 2.13 Linking C6400 Code With C6200/C6700/Older C6400 Object Code................................................ 50 2.14 Using Interlist ............................................................................................................... 50 2.15 Enabling Entry Hook and Exit Hook Functions......................................................................... 51 3 Optimizing Your Code ............................................................................................... 53 3.1 Invoking Optimization ...................................................................................................... 54 3.2 Optimizing Software Pipelining ........................................................................................... 55 3.2.1 Turn Off Software Pipelining (--disable_software_pipelining Option)....................................... 56 3.2.2 Software Pipelining Information ................................................................................. 56 3.2.3 Collapsing Prologs and Epilogs for Improved Performance and Code Size .............................. 60 3.3 Redundant Loops .......................................................................................................... 62 3.4 Utilizing the Loop Buffer Using SPLOOP on C6400+ and C6740 ................................................... 63 3.5 Reducing Code Size (--opt_for_space (or -ms) Option) .............................................................. 63 3.6 Performing File-Level Optimization (--opt_level=3 option)............................................................ 64 3.6.1 Controlling File-Level Optimization (--std_lib_func_def Options) ........................................... 64 3.6.2 Creating an Optimization Information File (--gen_opt_info Option)......................................... 64 3.7 Performing Program-Level Optimization (--program_level_compile and --opt_level=3 options)................. 65 3.7.1 Controlling Program-Level Optimization (--call_assumptions Option)...................................... 65 3.7.2 Optimization Considerations When Mixing C/C++ and Assembly .......................................... 66 3.8 Using Feedback Directed Optimization.................................................................................. 67 3.8.1 Feedback Directed Optimization ................................................................................ 67 3.8.2 Profile Data Decoder.............................................................................................. 69 3.8.3 Code Coverage.................................................................................................... 70 3.8.4 Feedback Directed Optimization API ........................................................................... 71 3.8.5 Feedback Directed Optimization Summary .................................................................... 71 3.9 Indicating Whether Certain Aliasing
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]
  • Using the GNU Compiler Collection (GCC)
    Using the GNU Compiler Collection (GCC) Using the GNU Compiler Collection by Richard M. Stallman and the GCC Developer Community Last updated 23 May 2004 for GCC 3.4.6 For GCC Version 3.4.6 Published by: GNU Press Website: www.gnupress.org a division of the General: [email protected] Free Software Foundation Orders: [email protected] 59 Temple Place Suite 330 Tel 617-542-5942 Boston, MA 02111-1307 USA Fax 617-542-2652 Last printed October 2003 for GCC 3.3.1. Printed copies are available for $45 each. Copyright c 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being \GNU General Public License" and \Funding Free Software", the Front-Cover texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled \GNU Free Documentation License". (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. i Short Contents Introduction ...................................... 1 1 Programming Languages Supported by GCC ............ 3 2 Language Standards Supported by GCC ............... 5 3 GCC Command Options .........................
    [Show full text]
  • The GNU Compiler Collection on Zseries
    The GNU Compiler Collection on zSeries Dr. Ulrich Weigand Linux for zSeries Development, IBM Lab Böblingen [email protected] Agenda GNU Compiler Collection History and features Architecture overview GCC on zSeries History and current status zSeries specific features and challenges Using GCC GCC optimization settings GCC inline assembly Future of GCC GCC and Linux Apache Samba mount cvs binutils gdb gcc Linux ls grep Kernel glibc DB2 GNU - essentials UDB SAP R/3 Unix - tools Applications GCC History Timeline January 1984: Start of the GNU project May 1987: Release of GCC 1.0 February 1992: Release of GCC 2.0 August 1997: EGCS project announced November 1997: Release of EGCS 1.0 April 1999: EGCS / GCC merge July 1999: Release of GCC 2.95 June 2001: Release of GCC 3.0 May/August 2002: Release of GCC 3.1/3.2 March 2003: Release of GCC 3.3 (estimated) GCC Features Supported Languages part of GCC distribution: C, C++, Objective C Fortran 77 Java Ada distributed separately: Pascal Modula-3 under development: Fortran 95 Cobol GCC Features (cont.) Supported CPU targets i386, ia64, rs6000, s390 sparc, alpha, mips, arm, pa-risc, m68k, m88k many embedded targets Supported OS bindings Unix: Linux, *BSD, AIX, Solaris, HP/UX, Tru64, Irix, SCO DOS/Windows, Darwin (MacOS X) embedded targets and others Supported modes of operation native compiler cross-compiler 'Canadian cross' builds GCC Architecture: Overview C C++ Fortran Java ... front-end front-end front-end front-end tree Optimizer rtx i386 s390 rs6000 sparc ... back-end back-end back-end
    [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]
  • 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]
  • Section “Common Predefined Macros” in the C Preprocessor
    The C Preprocessor For gcc version 12.0.0 (pre-release) (GCC) Richard M. Stallman, Zachary Weinberg Copyright c 1987-2021 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation. A copy of the license is included in the section entitled \GNU Free Documentation License". This manual contains no Invariant Sections. The Front-Cover Texts are (a) (see below), and the Back-Cover Texts are (b) (see below). (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. i Table of Contents 1 Overview :::::::::::::::::::::::::::::::::::::::: 1 1.1 Character sets:::::::::::::::::::::::::::::::::::::::::::::::::: 1 1.2 Initial processing ::::::::::::::::::::::::::::::::::::::::::::::: 2 1.3 Tokenization ::::::::::::::::::::::::::::::::::::::::::::::::::: 4 1.4 The preprocessing language :::::::::::::::::::::::::::::::::::: 6 2 Header Files::::::::::::::::::::::::::::::::::::: 7 2.1 Include Syntax ::::::::::::::::::::::::::::::::::::::::::::::::: 7 2.2 Include Operation :::::::::::::::::::::::::::::::::::::::::::::: 8 2.3 Search Path :::::::::::::::::::::::::::::::::::::::::::::::::::: 9 2.4 Once-Only Headers::::::::::::::::::::::::::::::::::::::::::::: 9 2.5 Alternatives to Wrapper #ifndef ::::::::::::::::::::::::::::::
    [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]
  • 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]
  • Microsoft Visual Studio: an Integrated Windows Program Development Environment
    Microsoft Visual Studio: An Integrated Windows Program Development Environment Microsoft Visual Studio • Self-contained environment for Windows program development: – Creating/editing – Compiling/linking (building) – Testing/debugging • IDE that accompanies Visual C++, Visual Basic, Visual C#, and other Microsoft Windows programming languages • See Chapter 2 & Appendix C of the Deitel text • Also Appendix C of the Gregory text Some Visual Studio Components • The Editors: C, C++, C#, VB source program text editors • cut/paste, color cues, indentation • generate source text files Resource Editors • Resources: Windows static data • Determine look and feel of an application – icons, bitmaps, cursors, menus, dialog boxes, etc. • graphical • generate resource script (.rc) files • integrated with text editor • created visually .NET Language Compilers • Unmanaged Code C/C++ Compiler – translates source programs to machine language – generates object (.obj) files for linker • Managed Code .NET Language Compilers – Many of them ? multi-language interoperability – Translate source programs to MSIL – Generate a “Portable Executable” that must be translated to target machine language by the CLR • Resource Compiler – Reads .rc file – Generates binary resource (.res) file for linker The Linker • Reads compiler .obj and .res files • Accesses C/C++/Windows libraries • Generates executable (.exe or .dll) Program Build and Run in the .NET Framework Common Language Runtime The Debugger • Powerful source code debugger • Integrated with all parts of Visual
    [Show full text]