Single Assignment vs. Multiple Assignment
7-3
Interrupts
7.2
Single Assignment vs. Multiple Assignment
Register allocation on the ’C6000 can be classified as either single assignment
or multiple assignment. Single assignment code is interruptible; multiple as-
signment is not interruptible. This section discusses the differences between
each and explains why only single assignment is interruptible.
Example 7–1 shows multiple assignment code. The term multiple assignment
means that a particular register has been assigned with more than one value
(in this case 2 values). On cycle 4, at the beginning of the ADD instruction, reg-
ister A1 is assigned to two different values. One value, written by the SUB in-
struction on cycle 1, already resides in the register. The second value is called
an
in-flight value and is assigned by the LDW instruction on cycle 2. Because
the LDW instruction does not actually write a value into register A1 until the end
of cycle 6, the assignment is considered in-flight.
In-flight operations cause code to be uninterruptible due to unpredictability.
Take, for example, the case where an interrupt is taken on cycle 3. At this point,
all instructions which have begun execution are allowed to complete and no
new instructions execute. So, 3 cycles after the interrupt is taken on cycle 3,
the LDW instruction writes to A1. After the interrupt service routine has been
processed, program execution continues on cycle 4 with the ADD instruction.
In this case, the ADD reads register A1 and will be reading the result of the
LDW, whereas normally the result of the SUB should be read. This unpredict-
ability means that in order to ensure correct operation, multiple assignment
code should not be interrupted and is thus, considered uninterruptible.
Example 7–1. Code With Multiple Assignment of A1
cycle
1
SUB
.S1
A4,A5,A1
; writes to A1 in single cycle
2
LDW
.D1
*A0,A1
; writes to A1 after 4 delay slots
3
NOP
4
ADD
.L1
A1,A2,A3
; uses old A1 (result of SUB)
5–6
NOP
2
7
MPY
.M1
A1,A4,A5
; uses new A1 (result of LDW)
Example 7–2 shows the same code with a new register allocation to produce
single assignment code. Now the LDW assigns a value to register A6 instead
of A1. Now, regardless of whether an interrupt is taken or not, A1 maintains
the value written by the SUB instruction because LDW now writes to A6. Be-
cause there are no in-flight registers that are read before an in-flight instruction
completes, this code is interruptible.