Keil Logo

Technical Support

On-Line Manuals

Compiler User Guide

Preface Overview of the Compiler Getting Started with the Compiler Compiler Features Compiler intrinsics Performance benefits of compiler intrinsics ARM assembler instruction intrinsics Generic intrinsics Compiler intrinsics for controlling IRQ and FIQ in Compiler intrinsics for inserting optimization bar Compiler intrinsics for inserting native instructi Compiler intrinsics for Digital Signal Processing Compiler support for European Telecommunications S Overflow and carry status flags for C and C++ code Texas Instruments (TI) C55x intrinsics for optimiz Compiler support for accessing registers using nam 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 o Compiler support for thread-local storage Compiler support for literal pools Compiler eight-byte alignment features Precompiled Header (PCH) files Automatic Precompiled Header (PCH) file processing Precompiled Header (PCH) file processing and the h Precompiled Header (PCH) file creation requirement Compilation with multiple Precompiled Header (PCH) Obsolete Precompiled Header (PCH) files Manually specifying the filename and location of a Selectively applying Precompiled Header (PCH) file Suppressing Precompiled Header (PCH) file processi Message output during Precompiled Header (PCH) pro Performance issues with Precompiled Header (PCH) f Default compiler options that are affected by opti Compiler Coding Practices Compiler Diagnostic Messages Using the Inline and Embedded Assemblers of the AR Compiler Command-line Options Language Extensions Compiler-specific Features C and C++ Implementation Details What is Semihosting? Via File Syntax Summary Table of GNU Language Extensions Standard C Implementation Definition Standard C++ Implementation Definition C and C++ Compiler Implementation Limits

Compiler support for literal pools

3.19 Compiler support for literal pools

Literal pools are areas of constant data in a code section.

No single instruction can generate a 4 byte constant, so the compiler generates code that loads these constants from a literal pool.
In the following example, the compiler generates code that loads the integer constant 0xdeadbeef from a literal pool (marked with ***).
int f(void) {
  return 0xdeadbeef;

** Section #1 '.text' (SHT_PROGBITS) [SHF_ALLOC + SHF_EXECINSTR]
    Size   : 12 bytes (alignment 4)
    Address: 0x00000000

      0x00000000: e59f0000  .... LDR    r0,[pc,#0] ; [0x8] = 0xdeadbeef
      0x00000004: e12fff1e  ../. BX     lr
      0x00000008: deadbeef  .... DCD  3735928559            ***
An alternative to using literal pools is to generate the constant in a register with a MOVW/MOVT instruction pair:
** Section #1 '.text' (SHT_PROGBITS) [SHF_ALLOC + SHF_EXECINSTR]
    Size   : 12 bytes (alignment 4)
    Address: 0x00000000

      0x00000000: e30b0eef  .... MOV    r0,#0xbeef
      0x00000004: e34d0ead  ..M. MOVT   r0,#0xdead
      0x00000008: e12fff1e  ../. BX     lr
In most cases, generating literal pools improves performance and code size. However, in some specific cases you might prefer to generate code without literal pools.
The following compiler options control literal pools:
  • --integer_literal_pools.
  • --string_literal_pools.
  • --branch_tables.
  • --float_literal_pools.
Non-ConfidentialPDF file icon PDF versionARM DUI0375H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.