Memory Banks
6-125
Optimizing Assembly Code via Linear Assembly
6.12.5 Linear Assembly for Unrolled FIR Inner Loop With .mptr Directive
Example 6–68 shows the unrolled FIR inner loop with the .mptr directive. The
.mptr directive allows the assembly optimizer to automatically determine if two
memory operations have a bank conflict by associating memory access infor-
mation with a specific pointer register.
If the assembly optimizer determines that two memory operations have a bank
conflict, then it will not schedule them in parallel. The .mptr directive tells the
assembly optimizer that when the specified register is used as a memory point-
er in a load or store instruction, it is initialized to point at a base lo <off-
set>, and is incremented a number of times each time through the loop.
Without the .mptr directives, the loads of x1 and h0 are scheduled in parallel,
and the loads of x2 and h1 are scheduled in parallel. This results in a 50%
chance of a memory conflict on every cycle.
Example 6–68. Linear Assembly for Full Unrolled FIR Filter
.global _fir
_fir:
.cproc
x, h, y
.reg
x_1, h_1, sum0, sum1, ctr, octr
.reg
p00, p01, p02, p03, p10, p11, p12, p13
.reg
x0, x1, x2, x3, h0, h1, h2, h3, rstx, rsth
ADD
h,2,h_1
; set up pointer to h[1]
MVK
50,octr
; outer loop ctr = 100/2
MVK
64,rstx
; used to rst x pointer each outer loop
MVK
64,rsth
; used to rst h pointer each outer loop
OUTLOOP:
ADD
x,2,x_1
; set up pointer to x[j+1]
SUB
h_1,2,h
; set up pointer to h[0]
MVK
8,ctr
; inner loop ctr = 32/2
ZERO
sum0
; sum0 = 0
ZERO
sum1
; sum1 = 0
[octr]
SUB
octr,1,octr
; decrement outer loop counter
.mptr
x, x+0
.mptr
x_1, x+2
.mptr
h, h+0
.mptr
h_1, h+2
LDH
.D2
*x++[2],x0
; x0 = x[j]