Memory Banks
6-127
Optimizing Assembly Code via Linear Assembly
6.12.6 Linear Assembly Resource Allocation
As the number of instructions in a loop increases, assigning a specific register
to every value in the loop becomes increasingly difficult. If 33 instructions in
a loop each write a value, they cannot each write to a unique register because
the ’C62x and ’C67x have only 32 registers. This would also work on the ’C64x
which has 64 registers. As a result, values that are not live on the same cycles
in the loop must share registers.
For example, in a 4-cycle loop:
-
If a value is written at the end of cycle 0 and read on cycle 2 of the loop,
it is live for two cycles (cycles 1 and 2 of the loop).
-
If another value is written at the end of cycle 2 and read on cycle 0 (the next
iteration) of the loop, it is also live for two cycles (cycles 3 and 0 of the loop).
Because both of these values are not live on the same cycles, they can occupy
the same register. Only after scheduling these instructions and their children
do you know that they can occupy the same register.
Register allocation is not complicated but can be tedious when done by hand.
Each value has to be analyzed for its lifetime and then appropriately combined
with other values not live on the same cycles in the loop. The assembly opti-
mizer handles this automatically after it software pipelines the loop. See the
TMS320C6000 Optimizing C/C++ Compiler User’s Guide for more informa-
tion.