Data Allocation Options

-autoregister

Enables automatic allocation of local variables to registers. This is the default.

-globalreg=n

n is a number from 0 to 4. Arguments to -globalreg= must be positive decimal integers. If this option is used, then the new, formerly illegal syntax is now valid:

register int i; /* file scope implies global */

However, register static int i is still illegal, because it can cause a possible register numbering problem when compiling multiple source files.

The type of global register variable can be any data type T, including struct and union, subject to the following restrictions:

For example,

register int x;
....
return &x;
....

On the MCore, the 4 registers 8, 9, 10, 11 are allocated, in that order, up to n<=4 registers, to hold the new global register variables. The MCore ABI designates all of these as permanent (non-volatile) registers, so they are saved and restored by library routines which use them.

These 4 registers are initialized to zero by the startup module. The program can depend on this, since it is necessary for ANSI C conformance.

You must use the same n for -globalreg=n for all compilations which are to be linked together.

It is an error to put a global variable into a register in one compilation but not into the same register in another compilation. You must be consistent across compilations.

If you want to share the same global register variables across compilations, consider placing them into a single include file, which is always included first in all compilations. This ensures absolute consistency of order and association of a variable with a given register, and vice versa.

MULTI works properly with both local (automatic) and global register variables, even if they are structs or unions.

Restrictions:

1. No library callbacks. A routine which is called by a library

routine cannot reliably access a global register variable, since

the contents of the particular register may have been saved by

the library routine and the register used for something else.

2. No interrupt routines. A routine which is called by an interrupt

routine may have interrupted a library routine, which leads to

the same restriction for the same reason given above.

You can work around these limitations by licensing the complete C runtime library source from Green Hills and recompiling the entire library with -globalreg=n.

-noautoregister

Disables automatic allocation of local variables to registers.

-nooverload

Does not allocate more than one variable to a register or a function.

-overload

Allocates more than one variable to a register. During debugging, this option should be turned off by -nooverload. [default]


Previous

Next



Copyright © 1999, Green Hills Software. All rights reserved.