Keil Logo

Technical Support

On-Line Manuals

Compiler Reference Guide

Preface armclang Command-line Options Compiler-specific Keywords and Operators Compiler-specific Function, Variable, and Type Att Function attributes __attribute__((always_inline)) function attribute __attribute__((cmse_nonsecure_call)) function attr __attribute__((cmse_nonsecure_entry)) function att __attribute__((const)) function attribute __attribute__((constructor(priority))) function at __attribute__((format_arg(string-index))) function __attribute__((interrupt("type"))) function attrib __attribute__((malloc)) function attribute __attribute__((naked)) function attribute __attribute__((noinline)) function attribute __attribute__((nonnull)) function attribute __attribute__((noreturn)) function attribute __attribute__((nothrow)) function attribute __attribute__((pcs("calling_convention"))) functio __attribute__((pure)) function attribute __attribute__((section("name"))) function attribut __attribute__((unused)) function attribute __attribute__((used)) function attribute __attribute__((value_in_regs)) function attribute __attribute__((visibility("visibility_type"))) fun __attribute__((weak)) function attribute __attribute__((weakref("target"))) function attrib Type attributes __attribute__((aligned)) type attribute __attribute__((packed)) type attribute __attribute__((transparent_union)) type attribute Variable attributes __attribute__((alias)) variable attribute __attribute__((aligned)) variable attribute __attribute__((deprecated)) variable attribute __attribute__((packed)) variable attribute __attribute__((section("name"))) variable attribut __attribute__((unused)) variable attribute __attribute__((used)) variable attribute __attribute__((visibility("visibility_type"))) var __attribute__((weak)) variable attribute __attribute__((weakref("target"))) variable attrib Compiler-specific Intrinsics Compiler-specific Pragmas Other Compiler-specific Features Standard C Implementation Definition Standard C++ Implementation Definition armclang Integrated Assembler armclang Inline Assembler

__attribute__((value_in_regs)) function attribute

3.20 __attribute__((value_in_regs)) function attribute

The value_in_regs function attribute is compatible with functions whose return type is a structure. It changes the calling convention of a function so that the returned structure is stored in the argument registers rather than being written to memory using an implicit pointer argument.

Note:

When using __attribute__((value_in_regs)), the calling convention only uses integer registers.

Syntax

__attribute__((value_in_regs)) return-type function-name([argument-list]);

Where:

return-type

is the type of the returned structure that conforms to certain restrictions as described in Restrictions.

Usage

Declaring a function __attribute__((value_in_regs)) can be useful when calling functions that return more than one result.

Restrictions

When targeting AArch32, the returned structure can be up to 16 bytes to fit in four 32-bit argument registers. When targeting AArch64, the returned structure can be up to 64 bytes to fit in eight 64-bit argument registers. If the structure returned by a function that is qualified by __attribute__((value_in_regs)) is too large, the compiler generates an error.

Each field of the returned structure must occupy exactly one or two integer registers, and must not require implicit padding of the structure. Anything else, including bitfields, is incompatible.

Nested structures are allowed with the same restriction that the nested structure as a whole and its individual members must occupy exactly one or two integer registers.

Unions are allowed if they have at least one maximal-size member that occupies exactly one or two integer registers. The other fields within the union can have any field type.

The allowed field types are:

  • signed int (AArch32 only).
  • unsigned int (AArch32 only).
  • signed long.
  • unsigned long.
  • signed long long.
  • unsigned long long.
  • pointer.
  • structure containing any of the types in this list.
  • union whose maximal-size member is any of the types in this list.

If the structure type returned by a function that is qualified by __attribute__((value_in_regs)) violates any of the preceding rules, then the compiler generates the corresponding error.

If a virtual function declared as __attribute__((value_in_regs)) is to be overridden, the overriding function must also be declared as __attribute__((value_in_regs)). If the functions do not match, the compiler generates an error.

A function that is declared as __attribute__((value_in_regs)) is not function-pointer-compatible with a normal function of the same type signature. If a pointer to a function that is declared as __attribute__((value_in_regs)) is initialized with a pointer to a function that is not declared as __attribute__((value_in_regs)), then the compiler generates a warning.

The return type of a function that is declared as__attribute__((value_in_regs)) must be known at the point of the function declaration. If the return type is an incomplete type, the compiler generates a corresponding error.

Example

struct ReturnType
{
    long a;
    void *ptr;
    union U
    {
       char c;
       short s;
       int i;
       float f;
       double d;
       struct S1 {long long ll;} s1;
    } u;
};

extern __attribute__((value_in_regs)) struct ReturnType g(long y);
Non-ConfidentialPDF file icon PDF version100067_0612_00_en
Copyright © 2014–2019 Arm Limited or its affiliates. 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.