04.01.2015 Views

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

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.

Compiler-specific Features<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 />

Caution<br />

You must take care when using global register variables because:<br />

• There is no check at link time to ensure that direct calls between different<br />

compilation units are sensible. If possible, define global register variables used in<br />

a program in each compilation unit of the program. In general, it is best to place<br />

the definition in a global header file. You must set up the value in the global<br />

register early in your code, before the register is used.<br />

• A global register variable maps to a callee-saved register, so its value is saved and<br />

restored across a call to a function in a compilation unit that does not use it as a<br />

global register variable, such as a library function.<br />

• Calls back into a compilation unit that uses a global register variable are<br />

dangerous. For example, if a function using a global register is called from a<br />

compilation unit that does not declare the global register variable, the function<br />

reads the wrong values from its supposed global register variables.<br />

• This storage class can only be used at file scope.<br />

Example<br />

Example 4-1 declares a global variable register allocated to r5.<br />

Example 4-1 Declaring a global integer register variable<br />

__global_reg(2) int x; v2 is the synonym for r5<br />

Example 4-2 on page 4-9 produces an error because global registers must be specified<br />

in all declarations of the same variable.<br />

4-8 Copyright © 2007-2010 <strong>ARM</strong>. All rights reserved. <strong>ARM</strong> DUI 0348C<br />

Non-Confidential,<br />

ID101213

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

Saved successfully!

Ooh no, something went wrong!