90
Section 2: Compiler
TI
-
89 / TI
-
92 Plus Sierra C Assembler Reference Manual
Not for Distribution
Beta Version February 2, 2001
Both p and q can be used to reference the characters ' a ', ' b ', and ' c '.
However, only q can be used to modify the character values. q is an array, the
contents of which are modifiable. p is a pointer initialized to point to a character
string, an array of characters which is not modifiable.
2.15. Compiler
Algorithms
This section describes the register allocation algorithm and the criteria used to
select between the three different switch statement algorithms.
2.15.1. Register
Allocation
The allocation of automatic variables to machine registers (data, address, and
floating-point) is a two-phase process. First, register candidates are selected.
Within a function there can be up to 32 register candidates. The default behavior
of the compiler is to select first the automatic variables that are declared with the
register keyword. If fewer than 32 automatic variables are declared register,
additional automatic variables that qualify for register allocation are classified as
register candidates. An automatic variable qualifies for allocation to a register if
its address is not taken and it is not an array or structure type. If there are 32 or
fewer automatic variables in a function that qualify for placement into registers,
they are all classified as register candidates. If there are more than 32 variables
that qualify, the qualifying variables that are not already declared register are
prioritized based on the number of times they appear in the function. On the
basis of their assigned priorities, the remaining variables are classified as register
candidates until all 32 slots are filled.
The
-Or#
flag can be used to influence which variables are selected to be
register candidates. The register candidate selection algorithm described above
is the default algorithm specified by the
-Or2
flag. The
-Or0
flag specifies that
no variables are to be considered register candidates. The
-Or1
flag specifies
that only variables declared register are register candidates. The
-Or3
flag
forces the register declaration to be ignored, but otherwise follows the default
selection algorithm. The
-Or3
flag allows the compiler to use its own judgment to
select the most appropriate register candidates. The
-Or4
flag prevents
floating-point variables that are not declared register from being considered as
register candidates. On an individual basis, automatic variables can be removed
from consideration as register candidates by applying the address-of operator
( & ). For example, the C statement '
&count;
' will not generate any code and will
guarantee that the variable count will not be placed in a register.
In the second phase of the register allocation process, the one or more lifetimes
of each register candidate are identified. For example, if a variable is used as a
loop counter in three non-nested loops and the variable is not referenced outside
any of the loops, then the variable is considered to have three discrete lifetimes.