SPNU151V January   1998  – February 2020

 

  1.   Read This First
    1.     About This Manual
    2.     Notational Conventions
    3.     Related Documentation
    4.     Related Documentation From Texas Instruments
    5.     Trademarks
  2. 1Introduction to the Software Development Tools
    1. 1.1 Software Development Tools Overview
    2. 1.2 Compiler Interface
    3. 1.3 ANSI/ISO Standard
    4. 1.4 Output Files
    5. 1.5 Utilities
  3. 2Using the C/C++ Compiler
    1. 2.1  About the Compiler
    2. 2.2  Invoking the C/C++ Compiler
    3. 2.3  Changing the Compiler's Behavior with Options
      1. 2.3.1  Linker Options
      2. 2.3.2  Frequently Used Options
      3. 2.3.3  Miscellaneous Useful Options
      4. 2.3.4  Run-Time Model Options
      5. 2.3.5  Symbolic Debugging and Profiling Options
      6. 2.3.6  Specifying Filenames
      7. 2.3.7  Changing How the Compiler Interprets Filenames
      8. 2.3.8  Changing How the Compiler Processes C Files
      9. 2.3.9  Changing How the Compiler Interprets and Names Extensions
      10. 2.3.10 Specifying Directories
      11. 2.3.11 Assembler Options
      12. 2.3.12 Deprecated Options
    4. 2.4  Controlling the Compiler Through Environment Variables
      1. 2.4.1 Setting Default Compiler Options (TI_ARM_C_OPTION)
      2. 2.4.2 Naming One or More Alternate Directories (TI_ARM_C_DIR)
    5. 2.5  Controlling the Preprocessor
      1. 2.5.1  Predefined Macro Names
      2. 2.5.2  The Search Path for #include Files
        1. 2.5.2.1 Adding a Directory to the #include File Search Path (--include_path Option)
      3. 2.5.3  Support for the #warning and #warn Directives
      4. 2.5.4  Generating a Preprocessed Listing File (--preproc_only Option)
      5. 2.5.5  Continuing Compilation After Preprocessing (--preproc_with_compile Option)
      6. 2.5.6  Generating a Preprocessed Listing File with Comments (--preproc_with_comment Option)
      7. 2.5.7  Generating Preprocessed Listing with Line-Control Details (--preproc_with_line Option)
      8. 2.5.8  Generating Preprocessed Output for a Make Utility (--preproc_dependency Option)
      9. 2.5.9  Generating a List of Files Included with #include (--preproc_includes Option)
      10. 2.5.10 Generating a List of Macros in a File (--preproc_macros Option)
    6. 2.6  Passing Arguments to main()
    7. 2.7  Understanding Diagnostic Messages
      1. 2.7.1 Controlling Diagnostic Messages
      2. 2.7.2 How You Can Use Diagnostic Suppression Options
    8. 2.8  Other Messages
    9. 2.9  Generating Cross-Reference Listing Information (--gen_cross_reference Option)
    10. 2.10 Generating a Raw Listing File (--gen_preprocessor_listing Option)
    11. 2.11 Using Inline Function Expansion
      1. 2.11.1 Inlining Intrinsic Operators
      2. 2.11.2 Inlining Restrictions
    12. 2.12 Using Interlist
      1.      Example 1. An Interlisted Assembly Language File
    13. 2.13 Controlling Application Binary Interface
    14. 2.14 VFP Support
    15. 2.15 Enabling Entry Hook and Exit Hook Functions
  4. 3Optimizing Your Code
    1. 3.1  Invoking Optimization
    2. 3.2  Controlling Code Size Versus Speed
    3. 3.3  Performing File-Level Optimization (--opt_level=3 option)
      1. 3.3.1 Creating an Optimization Information File (--gen_opt_info Option)
    4. 3.4  Program-Level Optimization (--program_level_compile and --opt_level=3 options)
      1. 3.4.1 Controlling Program-Level Optimization (--call_assumptions Option)
      2. 3.4.2 Optimization Considerations When Mixing C/C++ and Assembly
    5. 3.5  Automatic Inline Expansion (--auto_inline Option)
    6. 3.6  Link-Time Optimization (--opt_level=4 Option)
      1. 3.6.1 Option Handling
      2. 3.6.2 Incompatible Types
    7. 3.7  Using Feedback Directed Optimization
      1. 3.7.1 Feedback Directed Optimization
        1. 3.7.1.1 Phase 1 -- Collect Program Profile Information
        2. 3.7.1.2 Phase 2 -- Use Application Profile Information for Optimization
        3. 3.7.1.3 Generating and Using Profile Information
        4. 3.7.1.4 Example Use of Feedback Directed Optimization
        5. 3.7.1.5 The .ppdata Section
        6. 3.7.1.6 Feedback Directed Optimization and Code Size Tune
        7. 3.7.1.7 Instrumented Program Execution Overhead
        8. 3.7.1.8 Invalid Profile Data
      2. 3.7.2 Profile Data Decoder
      3. 3.7.3 Feedback Directed Optimization API
      4. 3.7.4 Feedback Directed Optimization Summary
    8. 3.8  Using Profile Information to Analyze Code Coverage
      1. 3.8.1 Code Coverage
        1. 3.8.1.1 Phase1 -- Collect Program Profile Information
        2. 3.8.1.2 Phase 2 -- Generate Code Coverage Reports
      2. 3.8.2 Related Features and Capabilities
        1. 3.8.2.1 Path Profiler
        2. 3.8.2.2 Analysis Options
        3. 3.8.2.3 Environment Variables
    9. 3.9  Accessing Aliased Variables in Optimized Code
    10. 3.10 Use Caution With asm Statements in Optimized Code
    11. 3.11 Using the Interlist Feature With Optimization
      1.      Example 1. The Function From Compiled With the -O2 and --optimizer_interlist Options
      2.      Example 2. The Function From Compiled with the --opt_level=2, --optimizer_interlist, and --c_src_interlist Options
    12. 3.12 Debugging and Profiling Optimized Code
      1. 3.12.1 Profiling Optimized Code
    13. 3.13 What Kind of Optimization Is Being Performed?
      1. 3.13.1  Cost-Based Register Allocation
      2. 3.13.2  Alias Disambiguation
      3. 3.13.3  Branch Optimizations and Control-Flow Simplification
      4. 3.13.4  Data Flow Optimizations
      5. 3.13.5  Expression Simplification
      6. 3.13.6  Inline Expansion of Functions
      7. 3.13.7  Function Symbol Aliasing
      8. 3.13.8  Induction Variables and Strength Reduction
      9. 3.13.9  Loop-Invariant Code Motion
      10. 3.13.10 Loop Rotation
      11. 3.13.11 Instruction Scheduling
      12. 3.13.12 Tail Merging
      13. 3.13.13 Autoincrement Addressing
      14. 3.13.14 Block Conditionalizing
        1.       Example 3. Block Conditionalizing C Source
        2.       Example 4. C/C++ Compiler Output for
      15. 3.13.15 Epilog Inlining
      16. 3.13.16 Removing Comparisons to Zero
      17. 3.13.17 Integer Division With Constant Divisor
      18. 3.13.18 Branch Chaining
  5. 4Linking C/C++ Code
    1. 4.1 Invoking the Linker Through the Compiler (-z Option)
      1. 4.1.1 Invoking the Linker Separately
      2. 4.1.2 Invoking the Linker as Part of the Compile Step
      3. 4.1.3 Disabling the Linker (--compile_only Compiler Option)
    2. 4.2 Linker Code Optimizations
      1. 4.2.1 Generate List of Dead Functions (--generate_dead_funcs_list Option)
      2. 4.2.2 Generating Aggregate Data Subsections (--gen_data_subsections Compiler Option)
    3. 4.3 Controlling the Linking Process
      1. 4.3.1 Including the Run-Time-Support Library
        1. 4.3.1.1 Automatic Run-Time-Support Library Selection
          1.        Example 1. Using the --issue_remarks Option
        2. 4.3.1.2 Manual Run-Time-Support Library Selection
        3. 4.3.1.3 Library Order for Searching for Symbols
      2. 4.3.2 Run-Time Initialization
      3. 4.3.3 Initialization of Cinit and Watchdog Timer Hold
      4. 4.3.4 Global Object Constructors
      5. 4.3.5 Specifying the Type of Global Variable Initialization
      6. 4.3.6 Specifying Where to Allocate Sections in Memory
      7. 4.3.7 A Sample Linker Command File
        1.       Example 2. Linker Command File
  6. 5C/C++ Language Implementation
    1. 5.1  Characteristics of ARM C
      1. 5.1.1 Implementation-Defined Behavior
    2. 5.2  Characteristics of ARM C++
    3. 5.3  Using MISRA C 2004
    4. 5.4  Using the ULP Advisor
    5. 5.5  Data Types
      1. 5.5.1 Size of Enum Types
    6. 5.6  File Encodings and Character Sets
    7. 5.7  Keywords
      1. 5.7.1 The const Keyword
      2. 5.7.2 The __interrupt Keyword
      3. 5.7.3 The volatile Keyword
        1.       Example 1. Volatile for Local Variables With setjmp
    8. 5.8  C++ Exception Handling
    9. 5.9  Register Variables and Parameters
      1. 5.9.1 Local Register Variables and Parameters
      2. 5.9.2 Global Register Variables
    10. 5.10 The __asm Statement
    11. 5.11 Pragma Directives
      1. 5.11.1  The CALLS Pragma
      2. 5.11.2  The CHECK_MISRA Pragma
      3. 5.11.3  The CHECK_ULP Pragma
      4. 5.11.4  The CODE_ALIGN Pragma
      5. 5.11.5  The CODE_SECTION Pragma
        1.       Example 2. Using the CODE_SECTION Pragma C Source File
        2.       Example 3. Generated Assembly Code From
      6. 5.11.6  The CODE_STATE Pragma
      7. 5.11.7  The DATA_ALIGN Pragma
      8. 5.11.8  The DATA_SECTION Pragma
        1.       Example 4. Using the DATA_SECTION Pragma C Source File
        2.       Example 5. Using the DATA_SECTION Pragma C++ Source File
        3.       Example 6. Using the DATA_SECTION Pragma Assembly Source File
      9. 5.11.9  The Diagnostic Message Pragmas
      10. 5.11.10 The DUAL_STATE Pragma
      11. 5.11.11 The FORCEINLINE Pragma
      12. 5.11.12 The FORCEINLINE_RECURSIVE Pragma
      13. 5.11.13 The FUNC_ALWAYS_INLINE Pragma
      14. 5.11.14 The FUNC_CANNOT_INLINE Pragma
      15. 5.11.15 The FUNC_EXT_CALLED Pragma
      16. 5.11.16 The FUNCTION_OPTIONS Pragma
      17. 5.11.17 The INTERRUPT Pragma
      18. 5.11.18 The LOCATION Pragma
      19. 5.11.19 The MUST_ITERATE Pragma
        1. 5.11.19.1 The MUST_ITERATE Pragma Syntax
        2. 5.11.19.2 Using MUST_ITERATE to Expand Compiler Knowledge of Loops
      20. 5.11.20 The NOINIT and PERSISTENT Pragmas
      21. 5.11.21 The NOINLINE Pragma
      22. 5.11.22 The NO_HOOKS Pragma
      23. 5.11.23 The once Pragma
      24. 5.11.24 The pack Pragma
      25. 5.11.25 The RESET_MISRA Pragma
      26. 5.11.26 The RESET_ULP Pragma
      27. 5.11.27 The RETAIN Pragma
      28. 5.11.28 The SET_CODE_SECTION and SET_DATA_SECTION Pragmas
        1.       Example 7. Setting Section With SET_DATA_SECTION Pragma
        2.       Example 8. Setting a Section With SET_CODE_SECTION Pragma
        3.       Example 9. Overriding SET_DATA_SECTION Setting
      29. 5.11.29 The SWI_ALIAS Pragma
        1.       Example 10. Using the SWI_ALIAS Pragma C Source File
        2.       Example 11. Generated Assembly File
      30. 5.11.30 The TASK Pragma
      31. 5.11.31 The UNROLL Pragma
      32. 5.11.32 The WEAK Pragma
    12. 5.12 The _Pragma Operator
    13. 5.13 Application Binary Interface
    14. 5.14 ARM Instruction Intrinsics
    15. 5.15 Object File Symbol Naming Conventions (Linknames)
    16. 5.16 Changing the ANSI/ISO C/C++ Language Mode
      1. 5.16.1 C99 Support (--c99)
      2. 5.16.2 C11 Support (--c11)
      3. 5.16.3 Strict ANSI Mode and Relaxed ANSI Mode (--strict_ansi and --relaxed_ansi)
    17. 5.17 GNU, Clang, and ACLE Language Extensions
      1. 5.17.1 Extensions
      2. 5.17.2 Function Attributes
      3. 5.17.3 Variable Attributes
      4. 5.17.4 Type Attributes
      5. 5.17.5 Built-In Functions
    18. 5.18 AUTOSAR
    19. 5.19 Compiler Limits
  7. 6Run-Time Environment
    1. 6.1  Memory Model
      1. 6.1.1 Sections
      2. 6.1.2 C/C++ System Stack
      3. 6.1.3 Dynamic Memory Allocation
    2. 6.2  Object Representation
      1. 6.2.1 Data Type Storage
        1. 6.2.1.1 char and short Data Types (signed and unsigned)
        2. 6.2.1.2 float, int, and long Data Types (signed and unsigned)
        3. 6.2.1.3 double, long double, and long long Data Types (signed and unsigned)
        4. 6.2.1.4 Pointer to Data Member Types
        5. 6.2.1.5 Pointer to Member Function Types
        6. 6.2.1.6 Structure and Array Alignment
      2. 6.2.2 Bit Fields
      3. 6.2.3 Character String Constants
    3. 6.3  Register Conventions
    4. 6.4  Function Structure and Calling Conventions
      1. 6.4.1 How a Function Makes a Call
      2. 6.4.2 How a Called Function Responds
      3. 6.4.3 C Exception Handler Calling Convention
      4. 6.4.4 Accessing Arguments and Local Variables
    5. 6.5  Accessing Linker Symbols in C and C++
    6. 6.6  Interfacing C and C++ With Assembly Language
      1. 6.6.1 Using Assembly Language Modules With C/C++ Code
      2. 6.6.2 Accessing Assembly Language Functions From C/C++
        1.       Example 1. Calling an Assembly Language Function From a C/C++ Program
        2.       Example 2. Assembly Language Program Called by
      3. 6.6.3 Accessing Assembly Language Variables From C/C++
        1. 6.6.3.1 Accessing Assembly Language Global Variables
          1.        Example 3. Assembly Language Variable Program
          2.        Example 4. C Program to Access Assembly Language From
        2. 6.6.3.2 Accessing Assembly Language Constants
          1.        Example 5. Accessing an Assembly Language Constant From C
          2.        Example 6. Assembly Language Program for
      4. 6.6.4 Sharing C/C++ Header Files With Assembly Source
      5. 6.6.5 Using Inline Assembly Language
      6. 6.6.6 Modifying Compiler Output
    7. 6.7  Interrupt Handling
      1. 6.7.1 Saving Registers During Interrupts
      2. 6.7.2 Using C/C++ Interrupt Routines
      3. 6.7.3 Using Assembly Language Interrupt Routines
      4. 6.7.4 How to Map Interrupt Routines to Interrupt Vectors
        1.       Example 7. Sample intvecs.asm File
      5. 6.7.5 Using Software Interrupts
      6. 6.7.6 Other Interrupt Information
    8. 6.8  Intrinsic Run-Time-Support Arithmetic and Conversion Routines
      1. 6.8.1 CPSR Register and Interrupt Intrinsics
    9. 6.9  Built-In Functions
    10. 6.10 System Initialization
      1. 6.10.1 Boot Hook Functions for System Pre-Initialization
      2. 6.10.2 Run-Time Stack
      3. 6.10.3 Automatic Initialization of Variables
        1. 6.10.3.1 Zero Initializing Variables
        2. 6.10.3.2 Direct Initialization
        3. 6.10.3.3 Autoinitialization of Variables at Run Time
        4. 6.10.3.4 Autoinitialization Tables
          1. 6.10.3.4.1 Length Followed by Data Format
          2. 6.10.3.4.2 Zero Initialization Format
          3. 6.10.3.4.3 Run Length Encoded (RLE) Format
          4. 6.10.3.4.4 Lempel-Ziv-Storer-Szymanski Compression (LZSS) Format
          5. 6.10.3.4.5 Sample C Code to Process the C Autoinitialization Table
            1.         Example 8. Processing the C Autoinitialization Table
        5. 6.10.3.5 Initialization of Variables at Load Time
        6. 6.10.3.6 Global Constructors
      4. 6.10.4 Initialization Tables
        1.       Example 9. Initialized Variables Defined in C
        2.       Example 10. Initialized Information for Variables Defined in
    11. 6.11 Dual-State Interworking Under TIABI (Deprecated)
      1. 6.11.1 Level of Dual-State Support
      2. 6.11.2 Implementation
        1. 6.11.2.1 Naming Conventions for Entry Points
        2. 6.11.2.2 Indirect Calls
          1.        Example 11. C Code Compiled for 16-BIS State: sum( )
          2.        Example 12. 16-Bit Assembly Program for
          3.        Example 13. C Code Compiled for 32-BIS State: sum( )
          4.        Example 14. 32-Bit Assembly Program for
  8. 7Using Run-Time-Support Functions and Building Libraries
    1. 7.1 C and C++ Run-Time Support Libraries
      1. 7.1.1 Linking Code With the Object Library
      2. 7.1.2 Header Files
      3. 7.1.3 Modifying a Library Function
      4. 7.1.4 Support for String Handling
      5. 7.1.5 Minimal Support for Internationalization
      6. 7.1.6 Allowable Number of Open Files
      7. 7.1.7 Nonstandard Header Files in the Source Tree
      8. 7.1.8 Library Naming Conventions
    2. 7.2 The C I/O Functions
      1. 7.2.1 High-Level I/O Functions
        1. 7.2.1.1 Formatting and the Format Conversion Buffer
      2. 7.2.2 Overview of Low-Level I/O Implementation
      3. 7.2.3 Device-Driver Level I/O Functions
      4. 7.2.4 Adding a User-Defined Device Driver for C I/O
        1.       Example 1. Mapping Default Streams to Device
      5. 7.2.5 The device Prefix
        1.       Example 2. Program for C I/O Device
    3. 7.3 Handling Reentrancy (_register_lock() and _register_unlock() Functions)
    4. 7.4 Library-Build Process
      1. 7.4.1 Required Non-Texas Instruments Software
      2. 7.4.2 Using the Library-Build Process
        1. 7.4.2.1 Automatic Standard Library Rebuilding by the Linker
        2. 7.4.2.2 Invoking mklib Manually
          1. 7.4.2.2.1 Building Standard Libraries
          2. 7.4.2.2.2 Shared or Read-Only Library Directory
          3. 7.4.2.2.3 Building Libraries With Custom Options
          4. 7.4.2.2.4 The mklib Program Option Summary
      3. 7.4.3 Extending mklib
        1. 7.4.3.1 Underlying Mechanism
        2. 7.4.3.2 Libraries From Other Vendors
  9. 8C++ Name Demangler
    1. 8.1 Invoking the C++ Name Demangler
    2. 8.2 Sample Usage of the C++ Name Demangler
      1.      Example 1. C++ Code for calories_in_a_banana
      2.      Example 2. Resulting Assembly for calories_in_a_banana
      3.      Example 3. Result After Running the C++ Name Demangler
  10.   A Glossary
    1.     A.1 Terminology
  11.   B Revision History
    1.     B.1 Recent Revisions

ARM Instruction Intrinsics

Assembly instructions can be generated using the intrinsics in the following tables. Table 5-3 shows which intrinsics are available on the different ARM targets. Table 5-4 shows the calling syntax for each intrinsic, along with the corresponding assembly instruction and a description. Additional intrinsices for getting and setting the CPSR register and to enable/disable interrupts are provided in Section 6.8.1.

Table 5-3 ARM Intrinsic Support by Target

C/C++ Compiler Intrinsic ARM V5e (ARM9E) ARM V6 (ARM11) ARM V6M0 (Cortex-M0) ARM V7M3 (Cortex-M3) ARM V7M4 (Cortex-M4) ARM V7R (Cortex-R4) ARM V7A8 (Cortex-A8)
_ _clz yes yes yes yes yes yes
_ _delay_cycles yes yes yes yes
_ _get_MSP yes yes yes
_ _get_PRIMASK yes yes yes
_ _ldrex yes yes yes yes yes
_ _ldrexb yes yes yes yes yes
_ _ldrexd yes yes yes
_ _ldrexh yes yes yes yes yes
_ _MCR yes yes yes yes yes yes
_ _MRC yes yes yes yes yes yes
_ _ nop yes yes yes yes yes yes yes
_norm yes yes yes yes yes yes
_ _rev yes yes yes yes yes
_ _rev16 yes yes yes yes yes
_ _revsh yes yes yes yes yes
_ _rbit yes yes yes yes
_ _ror yes yes yes yes yes yes yes
_pkhbt yes yes yes yes
_pkhtb yes yes yes yes
_qadd16 yes yes yes yes
_qadd8 yes yes yes yes
_qaddsubx yes yes yes yes
_qsub16 yes yes yes yes
_qsub8 yes yes yes yes
_qsubaddx yes yes yes yes
_sadd yes yes yes yes yes
_sadd16 yes yes yes yes
_sadd8 yes yes yes yes
_saddsubx yes yes yes yes
_sdadd yes yes yes yes yes
_sdsub yes yes yes yes yes
_sel yes yes yes yes
_ _set_MSP yes yes yes
_ _set_PRIMASK yes yes yes
_shadd16 yes yes yes yes
_shadd8 yes yes yes yes
_shsub16 yes yes yes yes
_shsub8 yes yes yes yes
_smac yes yes yes yes yes
_smlabb yes yes yes yes yes
_smlabt yes yes yes yes yes
_smlad yes yes yes yes
_smladx yes yes yes yes
_smlalbb yes yes yes yes yes
_smlalbt yes yes yes yes yes
_smlald yes yes yes yes
_smlaldx yes yes yes yes
_smlaltb yes yes yes yes yes
_smlaltt yes yes yes yes yes
_smlatb yes yes yes yes yes
_smlatt yes yes yes yes yes
_smlawb yes yes yes yes yes
_smlawt yes yes yes yes yes
_smlsd yes yes yes yes
_smlsdx yes yes yes yes
_smlsld yes yes yes yes
_smlsldx yes yes yes yes
_smmla yes yes yes yes
_smmlar yes yes yes yes
_smmls yes yes yes yes
_smmlsr yes yes yes yes
_smmul yes yes yes yes
_smmulr yes yes yes yes
_smuad yes yes yes yes
_smuadx yes yes yes yes
_smusd yes yes yes yes
_smusdx yes yes yes yes
_smpy yes yes yes yes yes
_smsub yes yes yes yes yes
_smulbb yes yes yes yes yes
_smulbt yes yes yes yes yes
_smultb yes yes yes yes yes
_smultt yes yes yes yes yes
_smulwb yes yes yes yes yes
_smulwt yes yes yes yes yes
_ _sqrt yes yes yes yes
_ _sqrtf yes yes yes yes yes
_ssat16 yes yes yes yes
_ssata yes yes yes yes yes yes
_ssatl yes yes yes yes yes yes
_ssub yes yes yes yes yes
_ssub16 yes yes yes yes
_ssub8 yes yes yes yes
_ssubaddx yes yes yes yes
_ _strex yes yes yes yes yes
_ _strexb yes yes yes yes yes
_ _strexd yes yes yes
_ _strexh yes yes yes yes yes
_subc yes yes yes yes yes
_sxtab yes yes yes yes
_sxtab16 yes yes yes yes
_sxtah yes yes yes yes
_sxtb yes yes yes yes yes yes
_sxtb16 yes yes yes yes
_sxth yes yes yes yes yes yes
_uadd16 yes yes yes yes
_uadd8 yes yes yes yes
_uaddsubx yes yes yes yes
_uhadd16 yes yes yes yes
_uhadd8 yes yes yes yes
_uhsub16 yes yes yes yes
_uhsub8 yes yes yes yes
_umaal yes yes yes yes
_uqadd16 yes yes yes yes
_uqadd8 yes yes yes yes
_uqaddsubx yes yes yes yes
_uqsub16 yes yes yes yes
_uqsub8 yes yes yes yes
_uqsubaddx yes yes yes yes
_usad8 yes yes yes yes
_usat16 yes yes yes yes
_usata yes yes yes yes yes yes
_usatl yes yes yes yes yes yes
_usub16 yes yes yes yes
_usub8 yes yes yes yes
_usubaddx yes yes yes yes
_uxtab yes yes yes yes
_uxtab16 yes yes yes yes
_uxtah yes yes yes yes
_uxtb yes yes yes yes yes yes
_uxtb16 yes yes yes yes
_uxth yes yes yes yes yes yes
_ _wfe yes yes yes yes yes
_ _wfi yes yes yes yes yes

Table 5-4 shows the calling syntax for each intrinsic, along with the corresponding assembly instruction and a description. See Table 5-3 for a list of which intrinsics are available on the different ARM targets. Additional intrinsices for getting and setting the CPSR register and to enable/disable interrupts are provided in Section 6.8.1.

Table 5-4 ARM Compiler Intrinsics

C/C++ Compiler Intrinsic Assembly
Instruction
Description
int count = _ _clz(int src); CLZcount, src Returns the count of leading zeros.
void _ _delay_cycles( unsigned int cycles); varies Delays execution for the specified number of cycles. The number of cycles must be a constant.

The __delay_cycles intrinsic inserts code to consume precisely the number of specified cycles with no side effects. The number of cycles delayed must be a compile-time constant.

Note: Cycle timing is based on 0 wait states. Results vary with additional wait states. The implementation does not account for dynamic prediction. Lower delay cycle counts may be less accurate given pipeline flush behaviors.

unsigned int dst = _ _get_MSP(void ); MRSdst, MSP Returns the current value of the Main Stack Pointer.
unsigned int dst = _ _get_PRIMASK(void ); MRSdst, PRIMASK Returns the current value of the Priority Mask Register. If this value is 1, activation of all exceptions with configurable priority is prevented.
unsigned int dest = _ _ldrex(void* src); LDREXdst, src Loads data from memory address containing word (32-bit) data
unsigned int dest= _ _ldrexb(void* src); LDREXBdst, src Loads data from memory address containing byte data
unsigned long long dest = _ _ldrexd(void* src); LDREXDdst, src Loads data from memory address with long long support
unsigned int dest = _ _ldrexh(void* src); LDREXHdst, src Loads data from memory address containing halfword (16-bit) data
void __MCR (unsigned int coproc, unsigned int opc1, unsigned int src, unsigned int coproc_reg1, unsigned int coproc_reg2, unsigned int opc2); MCRcoproc, opc1, src, CR<coproc_reg1>, CR<coproc_reg2>, opc2 Access the coprocessor registers
unsigned int __MRC(unsigned int coproc, unsigned int opc1, unsigned int coproc_reg1, unsigned int coproc_reg2, unsigned int opc2); MRCcoproc, opc1, src, CR<coproc_reg1>, CR<coproc_reg2>, opc2 Access the coprocessor registers
void _ _nop( void ); NOP Perform an instruction that does nothing.
int dst = _norm(int src); CLZdst, src Count leading zero bits. This intrinsic can be used when implementing integer normalization.
int dst = _pkhbt(int src1, int src2, int shift); PKHBTdst , src1 , src2 , #shift Combine bottom halfword of src1 with shifted top halfword of src2
nt dst = _pkhtb(int src1, int src2, int shift); PKHTBdst , src1 , src2 , #shift Combine top halfword of src1 with shifted bottom halfword of src2
int dst = _qadd16(int src1, int src2 ); QADD16dst, src1, src2 Performs two signed halfword saturated additions
int dst = _qadd8(int src1, int src2 ); QADD8dst, src1, src2 Performs four signed saturated 8-bit additions
int dst = _qaddsubx(int src1, int src2); QASXdst , src1 , src2 Exchange halfwords of src2, perform signed saturated addition on the top halfwords and signed saturated subtraction on the bottom halfwords.
int dst = _qsub16(int src1, int src2 ); QSUB16dst, src1, src2 Performs two signed saturated halfword subtractions
int dst = _qsub8(int src1, int src2 ); QSUB8dst, src1, src2 Performs four signed saturated 8-bit subtractions
int dst = _qsubaddx(int src1, int src2); QSAXdst , src1 , src2 Exchange halfwords of src2, perform signed saturated subtraction on top halfwords and signed saturated addition on bottom halfwords
int dst = _ _rbit(int src); RBITdst, src Reverses the bit order in a word.
int dst = _ _rev(int src); REVdst, src Reverses byte order in a word. That is, converts 32-bit data between big-endian and little-endian or vice versa.
int dst = _ _rev16(int src); REV16dst, src Reverses byte order in each byte in a word independently. That is, converts 16-bit data between big-endian and little-endian or vice versa.
int dst = _ _revsh(int src); REVSHdst, src Reverses byte order in the lower byte of a word, and extends the sign to 32 bits. That is, converts 16-bit signed data to 32-bit signed data, while also converting between big-endian and little-endian or vice versa.
int dst = _ _ror(int src , int shift); RORdst, src, shift Rotates the value to the right by the number of bits specified. Bits rotated off the right end are placed into empty bits on the left.
int dst =_sadd(int src1, int src2); QADDdst, src1, src2 Saturated add
int dst = _sadd16(int src1, int src2); SADD16dst , src1 , src2 Performs two signed halfword additions
int dst = _sadd8(int src1, int src2); SADD8dst , src1 , src2 Performs four signed 8-bit additions
int dst = _saddsubx(int src1, int src2); SASXdst , src1 , src2 Exchange halfwords of src2, add the top halfwords and subtract the bottom halfwords
int dst =_sdadd(int src1, int src2); QDADDdst, src1, src2 Saturated double-add
int dst =_sdsub(int src1, int src2); QDSUBdst, src1, src2 Saturated double-subtract
int dst = _sel(int src1, int src2); SELdst , src1 , src2 Selects byte n from src1 if GE bit n is set or from src2 if GE bit n is not set, where n ranges from 0 to 3.
void _ _set_MSP(unsigned int src); MSR MSP,src Sets the value of the Main Stack Pointer to src.
unsigned int dst = _ _set_PRIMASK(unsigned int src); MRSdst, PRIMASK (optional)
MSR PRIMASK,src
Sets the Priority Mask Register to the src value and returns the value as it was prior to being set as dst. Setting this register to 1 prevents the activation of all exceptions with configurable priority.
int dst = _shadd16(int src1, int src2); SHADD16dst , src1 , src2 Performs two signed halfword additions and halves the results
int dst = _shadd8(int src1, int src2); SHADD8dst , src1 , src2 Performs four signed 8-bit additions and halves the results
int dst = _shsub16(int src1, int src2); SHSUB16dst , src1 , src2 Performs two signed halfword subtractions and halves the results
int dst = _shsub8int src1, int src2); SHSUB8dst , src1 , src2 Performs four signed 8-bit subtractions and halves the results
int dst =_smac(int dst, int src1, int src2); SMULBBtmp, src1, src2
QDADDdst, dst, tmp
Saturated multiply-accumulate
int dst =_smlabb(int dst, short src1, short src2); SMLABBdst, src1, src2 Signed multiply-accumulate bottom halfwords
int dst =_smlabt(int dst, short src1, int src2); SMLABTdst, src1, src2 Signed multiply-accumulate bottom and top halfwords
int dst_smlad(int src1, int src2, int acc); SMLADdst , src1 , src2, acc Performs two signed 16-bit multiplications on the top and bottom halfwords of src1 and src2 and adds the results to acc.
int dst_smladx(int src1, int src2, int acc); SMLADXdst , src1 , src2, acc Same as _smlad except the halfwords in src2 are exchange before the multiplication.
long long dst =_smlalbb(long long dst, short src1, short src2); SMLALBBdstlo, dsthi, src1, src2 Signed multiply-long and accumulate bottom halfwords
long long dst =_smlalbt(long long dst, short src1, int src2); SMLALBTdstlo, dsthi, src1, src2 Signed multiply-long and accumulate bottom and top halfwords
long long dst_smlald(long long acc , int src1, int src2); SMLALDdst , src1 , src2 Performs two 16-bit multiplication on the top and bottom halfwords of src1 and src2 and adds the results to the 64-bit acc operand
long long dst_smlaldx(long long acc , int src1, int src2); SMLALDXdst , src1 , src2 Same as _smlald except the halfwords in src2 are exchanged.
long long dst =_smlaltb(long long dst, int src1, short src2); SMLALTBdstlo, dsthi, src1, src2 Signed multiply-long and accumulate top and bottom halfwords
long long dst =_smlaltt(long long dst, int src1, int src2); SMLALTTdstlo, dsthi, src1, src2 Signed multiply-long and accumulate top halfwords
int dst =_smlatb(int dst, int src1, short src2); SMLATBdst, src1, src2 Signed multiply-accumulate top and bottom halfwords
int dst =_smlatt(int dst, int src1, int src2); SMLATTdst, src1, src2 Signed multiply-accumulate top halfwords
int dst_smlawb(int src1, short src2, int acc); SMLAWBdst, src1, src2 Signed multiply-accumulate word and bottom halfword
int dst_smlawt(int src1, short src2, int acc); SMLAWTdst, src1, src2 Signed multiply-accumulate word and top halfword
int dst_smlsd(int src1, int src2, int acc); SMLSDdst , src1 , src2, acc Performs two signed 16-bit multiplications on the top and bottom halfwords of src1 and src2 and adds the difference of the results to acc.
int dst_smlsdx(int src1, int src2, int acc); SMLSDXdst , src1 , src2, acc Same as _smlsd except the halfwords in src2 are exchange before the multiplication.
long long dst_smlsld(long long acc , int src1, int src2); SMLSLDdst , src1 , src2 Performs two 16-bit multiplication on the top and bottom halfwords of src1 and src2 and adds the difference of the results to the 64-bit acc operand.
long long dst_smlsldx(long long acc , int src1, int src2); SMLSLDXdst , src1 , src2 Same as _smlsld except the halfwords in src2 are exchanged.
int dst_smmla(int src1, int src2, int acc); SMMLAdst , src1 , src2, acc Performs a signed multiplication on src1 and src2, extracts the most significant 32 bits of the result, and adds an accumulate value.
int dst_smmlar(int src1, int src2, int acc); SMMLARdst , src1 , src2, acc Same as _smmla execpt the result is rounded instead of being truncated.
int dst_smmls(int src1, int src2, int acc); SMMLSdst , src1 , src2, acc Performs a signed multiplication on src1 and src2, subtracts the result from an accumulate value that is shifted left by 32 bits, and extracts the most significant 32 bits of the result of the subtraction.
int dst_smmlsr(int src1, int src2, int acc); SMMLSRdst , src1 , src2, acc Same as _smmls except the result is rounded instead of being truncated.
int dst_smmul(int src1, int src2, int acc); SMMULdst , src1 , src2, acc Performs a signed 32-bit multiplication on src1 and src2 and extracts the most significant 32-bits of the result.
int dst_smmulr(int src1, int src2, int acc); SMMULRdst , src1 , src2, acc Same as _smmul except the result is rounded instead of being truncated.
int dst =_smpy(int src1, int src2); SMULBBdst, src1, src2
QADDdst, dst, dst
Saturated multiply
int dst =_smsub(int src1, int src2); SMULBBtmp, src1, src2
QDSUBdst, dst, tmp
Saturated multiply-subtract
int dst_smuad(int src1, int src2); SMUADdst , src1 , src2 Performs two signed 16-bit multiplications on the top and bottom halfwords and adds the products.
int dst_smuadx(int src1, int src2); SMUADXdst , src1 , src2 Same as _smuad except the halfwords in src2 are exchange before the multiplication.
int dst =_smulbb(int src1, int src2); SMULBBdst, src1, src2 Signed multiply bottom halfwords
int dst =_smulbt(int src1, int src2); SMULBTdst, src1, src2 Signed multiply bottom and top halfwords
int dst =_smultb(int src1, int src2); SMULTBdst, src1, src2 Signed multiply top and bottom halfwords
int dst =_smultt(int src1, int src2); SMULTTdst, src1, src2 Signed multiply top halfwords
int dst_smulwb(int src1, short src2, int acc); SMULWBdst, src1, src2 Signed multiply word and bottom halfword
int dst_smulwt(int src1, short src2, int acc); SMULWTdst, src1, src2 Signed multiply word and top halfword
int dst_smusd(int src1, int src2); SMUSDdst , src1 , src2 Performs two signed 16-bit multiplications on the top and bottom halfwords and subtracts the products.
int dst_smusdx(int src1, int src2); SMUSDXdst , src1 , src2 Same as _smusd except the halfwords in src2 are exchanged before the multiplication.
double __sqrt( double ); VSQRTdst , src1 Return the square root of the specified double. This intrinsic is directly replaced with the VSQRT instruction if --fp_mode=relaxed. If strict floating point mode is used, the function must also set an errno if a domain error occurs.
float __sqrtf( float ); VSQRTdst , src1 Return the square root of the specified float. This intrinsic is directly replaced with the VSQRT instruction if --fp_mode=relaxed. If strict floating point mode is used, the function must also set an errno if a domain error occurs.
int dst =_ssat16(int src, int bitpos); SSAT16dst, #bitpos Performs two halfword saturations to a selectable signed range specified by bitpos
int dst =_ssata(int src, int shift , int bitpos); SSATdst, #bitpos,src, ASR #shift Right shifts src and saturates to a selectable signed range specified by bitpos
int dst =_ssatl(int src , int shift , int bitpos); SSATdst, #bitpos,src, LSL #shift Left shifts src and saturates to a selectable signed range specified by bitpos
int dst =_ssub(int src1, int src2); QSUBdst, src1, src2 Saturated subtract
int dst = _ssub16(int src1, int src2); SSUB16dst , src1 , src2 Performs two signed halfword subtractions
int dst = _ssub8(int src1, int src2); SSUB8dst , src1 , src2 Performs four signed 8-bit subtractions
int dst = _ssubaddx(int src1, int src2); SSAXdst , src1 , src2 Exchange halfwords of src2, subtract the top halfwords and add the bottom halfwords
int status = _ _strex(unsigned int src, void* dst); STREXstatus, src, dest Stores word (32-bit) data in memory address
int status = _ _strexb(unsigned char src, void* dst); STREXBstatus, src, dest Stores byte data in memory address
int status = _ _strexd(unsigned long long src, void* dst); STREXDstatus, src, dest Stores long long data in memory address
int status = _ _strexh(unsigned short src, void* dst); STREXHstatus, src, dest Stores halfword (16-bit) data in memory address
int dst = _subc(int src1, int src2); SUBCdst, src1, src2 Subtract with carry
int dst_sxtab(int src1, int src2, int rotamt); SXTABdst, src1, src2, ROR #rotamt Extracts an optionally rotated 8-bit value from src2 and sign extends it to 32 bits, then adds the value to src1. The rotation amount can be 0, 8, 16, or 24.
int dst_sxtab16(int src1, int src2, int rotamt); SXTAB16dst, src1, src2, ROR #rotamt Extracts two optionally rotated 8-bit values from src2 and sign extends them to 16 bits each, then adds the values to the two 16-bit values in src1. The rotation amount should be 0, 8, 16, or 24.
int dst_sxtah(int src1, int src2, int rotamt); SXTAHdst, src1, src2, ROR #rotamt Extracts an optionally rotated 16-bit value from src2 and sign extends it to 32 bits, then adds the result to src1. The rotation amount can be 0, 8, 16, or 32.
int dst_sxtb(int src1, int rotamt); SXTBdst, src1, ROR #rotamt Extracts an optionally rotated 8-bit value from src1 and sign extends it to 32 bits. The rotation amount can be 0, 8, 16, or 24.
int dst_sxtb16(int src1, int rotamt); SXTAB16dst, src1, ROR #rotamt Extracts two optionally rotated 8-bit values from src1 and sign extends them to 16-bits. The rotation amount can be 0, 8, 16, or 24.
int dst_sxth(int src1, int rotamt); SXTHdst, src1, ROR #rotamt Extracts an optionally rotated 16-bit value from src2 and sign extends it to 32 bits. The rotation amount can be 0, 8, 16, or 24.
int dst = _uadd16(int src1, int src2); UADD16dst , src1 , src2 Performs two unsigned halfword additions
int dst = _uadd8(int src1, int src2); UADD8dst , src1 , src2 Performs four unsigned 8-bit additions
int dst = _uaddsubx(int src1, int src2); UASXdst , src1 , src2 Exchange halfwords of src2, add the top halfwords and subtract the bottom halfwords
int dst = _uhadd16(int src1, int src2); UHADD16dst , src1 , src2 Performs two unsigned halfword additions and halves the results
int dst = _uhadd8(int src1, int src2); UHADD8dst , src1 , src2 Performs four unsigned 8-bit additions and halves the results
int dst = _uhsub16(int src1, int src2); UHSUB16dst , src1 , src2 Performs two unsigned halfword subtractions and halves the results
int dst = _uhsub8(int src1, int src2); UHSUB8dst , src1 , src2 Performs four unsigned 8-bit subtractions and halves the results
int dst = _umaal(long long acc , int src1 , int src2 ); UMAALdst1 , dst2 , src1, src2 Performs an unsigned 32-bit multiplication on src1 and src2, then adds two unsigned 32-bit values in acc.
int dst = _uqadd16(int src1, int src2); UQADD16dst , src1 , src2 Performs two unsigned halfword saturated additions
int dst = _uqadd8(int src1, int src2); UQADD8dst , src1 , src2 Performs four unsigned saturated 8-bit additions
int dst = _uqaddsubx(int src1, int src2); UQASXdst , src1 , src2 Exchange halfwords of src2, perform unsigned saturated addition on the top halfwords and unsigned saturated subtraction on the bottom halfwords.
int dst = _uqsub16(int src1, int src2); UQSUB16dst , src1 , src2 Performs two unsigned saturated halfword subtractions
int dst = _uqsub8(int src1, int src2); UQSUB8dst , src1 , src2 Performs four unsigned saturated 8-bit subtractions
int dst = _uqsubaddx(int src1, int src2); UQSAXdst , src1 , src2 Exchange halfwords of src2, perform unsigned saturated subtraction on top halfwords and unsigned saturated addition on bottom halfwords
int dst = _usad8(int src1, int src2); USAD8dst , src1 , src2 Performs four unsigned 8-bit subtractions, and adds the absolute value of the differences together.
int dst =_usat16(int src, int bitpos); USAT16dst, #bitpos Performs two halfword saturations to a selectable unsigned range specified by bitpos
int dst =_usata(int src, int shift, int bitpos); USATdst, #bitpos,src, ASR #shift Right shifts src and saturates to a selectable unsigned range specified by bitpos
int dst =_usatl(int src, int shift, int bitpos); USATdst, #bitpos,src, LSL #shift Left shifts src and saturates to a selectable unsigned range specified by bitpos
int dst = _usub16(int src1, int src2); USUB16dst , src1 , src2 Performs two unsigned halfword subtractions
int dst = _usub8(int src1, int src2); USUB8dst , src1 , src2 Performs four unsigned 8-bit subtractions
int dst = _usubaddx(int src1, int src2); USAXdst , src1 , src2 Exchange halfwords of src2, subtract the top halfwords and add the bottom halfwords
int dst_uxtab(int src1, int src2, int rotamt); UXTABdst, src1, src2, ROR #rotamt Extracts an optionally rotated 8-bit value from src2 and zero extends it to 32 bits, then adds the value to src1. The rotation amount can be 0, 8, 16, or 24.
int dst_uxtab16(int src1, int src2, int rotamt); UXTAB16dst, src1, src2, ROR #rotamt Extracts two optionally rotated 8-bit values from src2 and zero extends them to 16 bits each, then adds the values to the two 16-bit values in src1. The rotation amount should be 0, 8, 16, or 24.
int dst_uxtah(int src1, int src2, int rotamt); UXTAHdst, src1, src2, ROR #rotamt Extracts an optionally rotated 16-bit value from src2 and zero extends it to 32 bits, then adds the result to src1. The rotation amount can be 0, 8, 16, or 32.
int dst_uxtb(int src1, int rotamt); UXTBdst, src1, ROR #rotamt Extracts an optionally rotated 8-bit value from src2 and zero extends it to 32 bits. The rotation amount can be 0, 8, 16, or 24.
int dst_uxtb16(int src1, int rotamt); UXTB16dst, src1, ROR #rotamt Extracts two optionally rotated 8-bit values from src1 and zero extends them to 16-bits. The rotation amount can be 0, 8, 16, or 24.
int dst_uxth(int src1, int rotamt); UXTHdst, src1, ROR #rotamt Extracts an optionally rotated 16-bit value from src2 and zero extends it to 32 bits. The rotation amount can be 0, 8, 16, or 24.
void _ _wfe( void ); WFE Wait for event. Save power by waiting for an exception or event..
void _ _wfi( void ); WFI Wait for interrupt. Enter standby, dormant or shutdown mode, where an interrupt is required to wake-up the processor.

In addition, the compiler supports many of the intrinsics described in the ARM C Language Extensions (ACLE) specification. These intrinsics are applicable for the Cortex-M and Cortex-R processor variants. The ACLE intrinsics are implemented in order to support the development of source code that can be compiled using ACLE-compliant compilers from multiple vendors for a variety of ARM processors. A number of the intrinsics are duplicates of intrinsics listed in the previous table but with slightly different names (such as one vs. two leading underscores).

The compiler does not support all of the ACLE intrinsics listed in the ACLE specification. For example, the __cls, __clsl, and __clsll ACLE intrinsics are not supported, because the CLS instruction is not available on the Cortex-M or Cortex-R architectures.

In order to use the ACLE intrinsics, your code must include the provided arm_acle.h header file. For details about the ACLE intrinsics, see the ACLE specification. For information about which ACLE intrinsics are supported, see the arm_acle.h file. Where applicable, the declarations of ACLE intrinsics that are not supported are enclosed in comments in that header file along with a brief explanation of why the intrinsic is not supported and a reference to the appropriate section in the ACLE specification where the intrinsic is described.