ARM® Compiler toolchain Using the Compiler

Version 5.0

List of Topics

Conventions and Feedback
Overview of the compiler
The compiler
Source language modes of the compiler
The C and C++ libraries
Getting started with the Compiler
Compiler command-line syntax
Compiler command-line options listed by group
Default compiler behavior
Order of compiler command-line options
Using stdin to input source code to the compiler
Directing output to stdout
Filename suffixes recognized by the compiler
Compiler output files
Factors influencing how the compiler searches for header files
Compiler command-line options and search paths
Compiler search rules and the current place
The ARMCCnnINC environment variable
Code compatibility between separately compiled and assembled modules
Linker feedback during compilation
Using GCC fallback when building applications
Unused function code
Minimizing code size by eliminating unused functions during compilation
Minimizing code size by reducing compilation required for interworking
Compilation build time
How to minimize compilation build time
Minimizing compilation build time with a single armcc invocation
Effect of --multifile on compilation build time
Minimizing compilation build time with parallel make
Compilation build time and operating system choice
Using the NEON Vectorizing Compiler
NEON technology
The NEON unit
Methods of writing code for NEON
Generating NEON instructions from C or C++ code
NEON C extensions
Automatic vectorization
Data references within a vectorizable loop
Stride patterns and data accesses
Factors affecting NEON vectorization performance
NEON vectorization performance goals
Recommended loop structure for vectorization
Data dependency conflicts when vectorizing code
Carry-around scalar variables and vectorization
Reduction of a vector to a scalar
Vectorization on loops containing pointers
Nonvectorization on loops containing pointers and indirect addressing
Nonvectorization on conditional loop exits
Vectorizable loop iteration counts
Indicating loop iteration counts to the compiler with __promise(expr)
Vectorizable and nonvectorizable use of structures
Grouping use of structures for vectorization
struct member lengths and vectorization
Nonvectorization of function calls to non-inline functions from within loops
Conditional statements and efficient vectorization
Vectorization diagnostics to tune code for improved performance
Vectorizable code example
DSP vectorizable code example
What can limit or prevent automatic vectorization
Compiler Features
Compiler intrinsics
Performance benefits of compiler intrinsics
ARM assembler instruction intrinsics supported by the compiler
Generic intrinsics supported by the compiler
Compiler intrinsics for controlling IRQ and FIQ interrupts
Compiler intrinsics for inserting optimization barriers
Compiler intrinsics for inserting native instructions
Compiler intrinsics for Digital Signal Processing (DSP)
European Telecommunications Standards Institute (ETSI) basic operations
Compiler support for European Telecommunications Standards Institute (ETSI) basic operations
Overflow and carry status flags for C and C++ code
Texas Instruments (TI) C55x intrinsics for optimizing C code
NEON intrinsics provided by the compiler
Using NEON intrinsics
Compiler support for accessing registers using named register variables
Pragmas recognized by the compiler
Compiler and processor support for bit-banding
Compiler type attribute, __attribute__((bitband))
--bitband compiler command-line option
How the compiler handles bit-band objects placed outside bit-band regions
Compiler support for thread-local storage
Compiler eight-byte alignment features
Using compiler and linker support for symbol versions
PreCompiled Header (PCH) files
Automatic PreCompiled Header (PCH) file processing
PreCompiled Header (PCH) file processing and the header stop point
PreCompiled Header (PCH) file creation requirements
Compilation with multiple PreCompiled Header (PCH) files
Obsolete PreCompiled Header (PCH) files
Manually specifying the filename and location of a PreCompiled Header (PCH) file
Selectively applying PreCompiled Header (PCH) file processing
Suppressing PreCompiled Header (PCH) file processing
Message output during PreCompiled Header (PCH) processing
Performance issues with PreCompiled Header (PCH) files
Default compiler options that are affected by optimization level
Compiler Coding Practices
The compiler as an optimizing compiler
Compiler optimization for code size versus speed
Compiler optimization levels and the debug view
Selecting the target CPU at compile time
Optimization of loop termination in C code
Loop unrolling in C code
Compiler optimization and the volatile keyword
Code metrics
Code metrics for measurement of code size and data size
Stack use in C and C++
Benefits of reducing debug information in objects and libraries
Methods of reducing debug information in objects and libraries
Guarding against multiple inclusion of header files
Methods of minimizing function parameter passing overhead
Functions that return multiple values through registers
Functions that return the same result when called with the same arguments
Comparison of pure and impure functions
Recommendation of postfix syntax when qualifying functions with ARM function modifiers
Inline functions
Compiler decisions on function inlining
Automatic function inlining and static functions
Inline functions and removal of unused out-of-line functions at link time
Automatic function inlining and multifile compilation
Restriction on overriding compiler decisions about function inlining
Compiler modes and inline functions
Inline functions in C++ and C90 mode
Inline functions in C99 mode
Inline functions and debugging
Types of data alignment
Advantages of natural data alignment
Compiler storage of data objects by natural byte alignment
Relevance of natural data alignment at compile time
Unaligned data access in C and C++ code
The __packed qualifier and unaligned data access in C and C++ code
Unaligned fields in structures
Performance penalty associated with marking whole structures as packed
Unaligned pointers in C and C++ code
Unaligned Load Register (LDR) instructions generated by the compiler
Detailed comparison of an unpacked struct, a __packed struct, and a struct with individually __packed fields
Compiler support for floating-point arithmetic
Default selection of hardware or software floating-point support
Example of hardware and software support differences for floating-point arithmetic
Vector Floating-Point (VFP) architectures
Limitations on hardware handling of floating-point arithmetic
Implementation of Vector Floating-Point (VFP) support code
Compiler and library support for half-precision floating-point numbers
Half-precision floating-point number format
Compiler support for floating-point computations and linkage
Types of floating-point linkage
Compiler options for floating-point linkage and computations
Integer division-by-zero errors in C code
About trapping integer division-by-zero errors with __aeabi_idiv0()
About trapping integer division-by-zero errors with __rt_raise()
Identification of integer division-by-zero errors in C code
Examining parameters when integer division-by-zero errors occur in C code
Software floating-point division-by-zero errors in C code
About trapping software floating-point division-by-zero errors
Identification of software floating-point division-by-zero errors
Software floating-point division-by-zero debugging
New language features of C99
New library features of C99
// comments in C99 and C90
Compound literals in C99
Designated initializers in C99
Hexadecimal floating-point numbers in C99
Flexible array members in C99
__func__ predefined identifier in C99
inline functions in C99
long long data type in C99 and C90
Macros with a variable number of arguments in C99
Mixed declarations and statements in C99
New block scopes for selection and iteration statements in C99
_Pragma preprocessing operator in C99
Restricted pointers in C99
Additional <math.h> library functions in C99
Complex numbers in C99
Boolean type and <stdbool.h> in C99
Extended integer types and functions in <inttypes.h> and <stdint.h> in C99
<fenv.h> floating-point environment access in C99
<stdio.h> snprintf family of functions in C99
<tgmath.h> type-generic math macros in C99
<wchar.h> wide character I/O functions in C99
How to prevent uninitialized data from being initialized to zero
Compiler Diagnostic Messages
Compiler diagnostics
Severity of compiler diagnostic messages
Options that change the severity of compiler diagnostic messages
Prefix letters in compiler diagnostic messages
Compiler exit status codes and termination messages
Compiler data flow warnings
Using the Inline and Embedded Assemblers of the ARM Compiler
Compiler support for inline assembly language
Inline assembler support in the compiler
Restrictions on inline assembler support in the compiler
Inline assembly language syntax with the __asm keyword in C and C++
Inline assembly language syntax with the asm keyword in C++
Inline assembler rules for compiler keywords __asm and asm
Restrictions on inline assembly operations in C and C++ code
Inline assembler register restrictions in C and C++ code
Inline assembler processor mode restrictions in C and C++ code
Inline assembler Thumb instruction set restrictions in C and C++ code
Inline assembler Vector Floating-Point (VFP) coprocessor restrictions in C and C++ code
Inline assembler instruction restrictions in C and C++ code
Miscellaneous inline assembler restrictions in C and C++ code
Inline assembler and register access in C and C++ code
Inline assembler and the # constant expression specifier in C and C++ code
Inline assembler and instruction expansion in C and C++ code
Expansion of inline assembler instructions that use constants
Expansion of inline assembler load and store instructions
Inline assembler effect on processor condition flags in C and C++ code
Inline assembler operands in C and C++ code
Inline assembler expression operands in C and C++ code
Inline assembler register list operands in C and C++ code
Inline assembler intermediate operands in C and C++ code
Inline assembler function calls and branches in C and C++ code
Behavior of BL and SVC without optional lists in C and C++ code
Inline assembler BL and SVC input parameter list in C and C++ code
Inline assembler BL and SVC output value list in C and C++ code
Inline assembler BL and SVC corrupted register list
Inline assembler branches and labels in C and C++ code
Inline assembler and virtual registers
Compiler support for embedded assembler
Embedded assembler syntax in C and C++
Effect of compiler ARM and Thumb states on embedded assembler
Restrictions on embedded assembly language functions in C and C++ code
Compiler generation of embedded assembly language functions
Access to C and C++ compile-time constant expressions from embedded assembler
Differences between expressions in embedded assembler and C or C++
Manual overload resolution in embedded assembler
__offsetof_base keyword for related base classes in embedded assembler
Compiler-supported keywords for calling class member functions in embedded assembler
__mcall_is_virtual(D, f)
__mcall_is_in_vbase(D, f)
__mcall_offsetof_vbase(D, f)
__mcall_this_offset(D, f)
__vcall_offsetof_vfunc(D, f)
Calling nonstatic member functions in embedded assembler
Calling a nonvirtual member function
Calling a virtual member function
Legacy inline assembler that accesses sp, lr, or pc
Accessing sp (r13), lr (r14), and pc (r15) in legacy code
Differences in compiler support of inline and embedded assembly code
Revisions for Using the Compiler

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.

Revision History
Revision A28 May 2010ARM Compiler toolchain v4.1 Release
Revision B30 September 2010Update 1 for ARM Compiler toolchain v4.1
Revision C28 January 2011Update 2 for ARM Compiler toolchain v4.1 Patch 3
Revision D30 April 2011ARM Compiler toolchain v5.0 Release
Revision E29 July 2011Update 1 for ARM Compiler toolchain v5.0
Copyright © 2010-2011 ARM. All rights reserved.ARM DUI 0472E