29.12.2014 Views

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Compiler</strong>-specific Features<br />

4.1.6 __global_reg<br />

The __global_reg storage class specifier allocates the declared variable to a global<br />

variable register.<br />

Syntax<br />

__global_reg(n) type varName<br />

Where:<br />

n<br />

type<br />

varName<br />

Is an integer between one and eight.<br />

Is one of the following types:<br />

• any integer type, except long long<br />

• any char type<br />

• any pointer type.<br />

Is the name of a variable.<br />

Restrictions<br />

If you use this storage class, you cannot use any additional storage class such as extern,<br />

static, or typedef.<br />

In C, global register variables cannot be qualified or initialized at declaration. In C++,<br />

any initialization is treated as a dynamic initialization.<br />

The number of available registers varies depending on the variant of the AAPCS being<br />

used, there are between five and seven registers available for use as global variable<br />

registers.<br />

In practice, it is recommended that you do not use more than:<br />

• three global register variables in <strong>ARM</strong> or Thumb-2<br />

• one global register variable in Thumb-1<br />

• half the number of available floating-point registers as global floating-point<br />

register variables.<br />

If you declare too many global variables, code size increases significantly. In some<br />

cases, your program might not compile.<br />

<strong>ARM</strong> DUI 0348A Copyright © 2007, 2010 <strong>ARM</strong> Limited. All rights reserved. 4-7<br />

Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!