ARM® Compiler Toolchain Version 4.1
Total Page:16
File Type:pdf, Size:1020Kb
ARM® Compiler toolchain Version 4.1 Using the Compiler Copyright © 2010-2011 ARM. All rights reserved. ARM DUI 0472C (ID080411) ARM Compiler toolchain Using the Compiler Copyright © 2010-2011 ARM. All rights reserved. Release Information The following changes have been made to this book. Change History Date Issue Confidentiality Change 28 May 2010 A Non-Confidential ARM Compiler toolchain v4.1 Release 30 September 2010 B Non-Confidential Update 1 for ARM Compiler toolchain v4.1 28 January 2011 C Non-Confidential Update 2 for ARM Compiler toolchain v4.1 Patch 3 30 April 2011 C Non-Confidential Update 3 for ARM Compiler toolchain v4.1 Patch 4 30 September 2011 C Non-Confidential Update 4 for ARM Compiler toolchain v4.1 Patch 5 Proprietary Notice Words and logos marked with ™ or ® are registered trademarks or trademarks of ARM in the EU and other countries, except as otherwise stated below in this proprietary notice. Other brands and names mentioned herein may be the trademarks of their respective owners. Neither the whole nor any part of the information contained in, or the product described in, this document may be adapted or reproduced in any material form except with the prior written permission of the copyright holder. The product described in this document is subject to continuous developments and improvements. All particulars of the product and its use contained in this document are given by ARM in good faith. However, all warranties implied or expressed, including but not limited to implied warranties of merchantability, or fitness for purpose, are excluded. This document is intended only to assist the reader in the use of the product. ARM shall not be liable for any loss or damage arising from the use of any information in this document, or any error or omission in such information, or any incorrect use of the product. Where the term ARM is used it means “ARM or any of its subsidiaries as appropriate”. Some material in this document is based on IEEE 754 - 1985 IEEE Standard for Binary Floating-Point Arithmetic. The IEEE disclaims any responsibility or liability resulting from the placement and use in the described manner. Confidentiality Status This document is Non-Confidential. The right to use, copy and disclose this document may be subject to license restrictions in accordance with the terms of the agreement entered into by ARM and the party that ARM delivered this document to. Product Status The information in this document is final, that is for a developed product. Web Address http://www.arm.com ARM DUI 0472C Copyright © 2010-2011 ARM. All rights reserved. ii ID080411 Non-Confidential Contents ARM Compiler toolchain Using the Compiler Chapter 1 Conventions and Feedback Chapter 2 Overview of the compiler 2.1 The compiler ................................................................................................................. 2-2 2.2 Source language modes of the compiler ...................................................................... 2-3 2.3 The C and C++ libraries ................................................................................................ 2-4 Chapter 3 Getting started with the Compiler 3.1 Compiler command-line syntax .................................................................................... 3-3 3.2 Compiler command-line options listed by group ........................................................... 3-4 3.3 Default compiler behavior ............................................................................................. 3-9 3.4 Order of compiler command-line options .................................................................... 3-11 3.5 Using stdin to input source code to the compiler ........................................................ 3-12 3.6 Directing output to stdout ............................................................................................ 3-14 3.7 Filename suffixes recognized by the compiler ............................................................ 3-15 3.8 Compiler output files ................................................................................................... 3-17 3.9 Factors influencing how the compiler searches for header files ................................. 3-18 3.10 Compiler command-line options and search paths ..................................................... 3-19 3.11 Compiler search rules and the current place .............................................................. 3-20 3.12 The ARMCC41INC environment variable ................................................................... 3-21 3.13 Code compatibility between separately compiled and assembled modules ............... 3-22 3.14 Linker feedback during compilation ............................................................................ 3-23 3.15 Unused function code ................................................................................................. 3-24 3.16 Minimizing code size by eliminating unused functions during compilation ................. 3-25 3.17 Minimizing code size by reducing compilation required for interworking .................... 3-26 3.18 Compilation build time ................................................................................................ 3-27 3.19 How to minimize compilation build time ...................................................................... 3-29 3.20 Minimizing compilation build time with a single armcc invocation .............................. 3-31 3.21 Effect of --multifile on compilation build time .............................................................. 3-32 ARM DUI 0472C Copyright © 2010-2011 ARM. All rights reserved. iii ID080411 Non-Confidential Contents 3.22 Minimizing compilation build time with parallel make ................................................. 3-33 3.23 Compilation build time and operating system choice .................................................. 3-34 Chapter 4 Using the NEON Vectorizing Compiler 4.1 NEON technology ......................................................................................................... 4-3 4.2 The NEON unit ............................................................................................................. 4-4 4.3 Methods of writing code for NEON ............................................................................... 4-6 4.4 Generating NEON instructions from C or C++ code ..................................................... 4-7 4.5 NEON C extensions ...................................................................................................... 4-8 4.6 Automatic vectorization ................................................................................................. 4-9 4.7 Data references within a vectorizable loop ................................................................. 4-10 4.8 Stride patterns and data accesses ............................................................................. 4-11 4.9 Factors affecting NEON vectorization performance ................................................... 4-12 4.10 NEON vectorization performance goals ..................................................................... 4-13 4.11 Recommended loop structure for vectorization .......................................................... 4-14 4.12 Data dependency conflicts when vectorizing code ..................................................... 4-15 4.13 Carry-around scalar variables and vectorization ........................................................ 4-17 4.14 Reduction of a vector to a scalar ................................................................................ 4-18 4.15 Vectorization on loops containing pointers ................................................................. 4-19 4.16 Nonvectorization on loops containing pointers and indirect addressing ..................... 4-21 4.17 Nonvectorization on conditional loop exits .................................................................. 4-22 4.18 Vectorizable loop iteration counts ............................................................................... 4-23 4.19 Indicating loop iteration counts to the compiler with __promise(expr) ........................ 4-25 4.20 Vectorizable and nonvectorizable use of structures ................................................... 4-27 4.21 Grouping use of structures for vectorization ............................................................... 4-28 4.22 struct member lengths and vectorization .................................................................... 4-29 4.23 Nonvectorization of function calls to non-inline functions from within loops ............... 4-30 4.24 Conditional statements and efficient vectorization ...................................................... 4-31 4.25 Vectorization diagnostics to tune code for improved performance ............................. 4-32 4.26 Vectorizable code example ......................................................................................... 4-34 4.27 DSP vectorizable code example ................................................................................. 4-37 4.28 What can limit or prevent automatic vectorization ...................................................... 4-40 Chapter 5 Compiler Features 5.1 About Profiler-guided optimization ................................................................................ 5-3 5.2 Profiler-guided optimizations with link-time code generation ........................................ 5-4 5.3 Compiler intrinsics .......................................................................................................