
5-36
Motorola DSP56000 Family Optimizing C Compiler User’s Manual
For More Information On This Product,
Go to: www.freescale.com
Motorola
Out-of-line Assembly Code
5.4.5 Optimization Techniques
The general template for out-of-line assembly code provides a clean template to build C
callable functions. However, the DSP56000 family microprocessor chips have powerful
features such as multiple instruction execution (multiply and accumulate) and parallel data
move operations that may allow additional optimization. After constructing the out-of-line
assembly code from the general template, some hand-optimization can be performed by
combining several assembly statements.
Information about these optimization techniques can be obtained from the
DSP56000/DSP56001 User’s Manual
. Some optimization techniques which are related to
the C compiler are discussed in this section but additional optimization can be achieved
using the architectural features described in the user’s manual.
The R0 register (which is updated by the out-of-line assembly code template prologue) is
required only when parameters are passed to the C function. If there are no parameters to
be passed, then the following two assembly code lines are not required and can be omitted:
move
lua
r0,y:(r6)+
(r6)+,r0
The return address (SSH) was saved in the out-of-line assembly code prologue but it is
only required when a C function calls another C function. A C function is called a leaf
function if it does not call any other C function. In leaf functions, the return address is not
needed and does not have to be saved.
Similarly the epilogue can be optimized in the same way as the prologue. For any leaf
function or non parameter C function, the epilogue size can be reduced by eliminating:
move
y:-(r6),ssh; for a leaf C function
or
move
y:-(r6),r0; for a non-parameter C function
The test statement “
tst a
” in the epilogue can be eliminated if the function does not return
any values. The test statement may be required due to the C compiler’s optimization
features since it provides condition flags for an
if
statement in a function call. For
example, if the out-of-line assembly function foo() is used in the statement
if(foo()) { },
then the C compiler will not generate code to test the return value when a
jcc
statement is
issued. This is primarily because the C compiler uses the condition flags which were
executed at the end of the epilogue of
foo()
.
A variety of optimizations can be achieved by combining the move instructions and main
program code to utilize parallel moves (see Section 5.4.5 and Section 5-38 which point out
possible optimizations in the comments). These and other DSP56000 specific
F
Freescale Semiconductor, Inc.
n
.