Achieving Optimal Performance from C/C++ Source Code
#pragma regs_clobbered
The
regs_clobbered
of code that makes function calls. The best use of the pragma is to increase
the number of call-preserved registers available across a function call.
There are two complementary ways in which this may be done.
First of all, suppose that you have a function written in assembly that you
wish to call from C source code. The
applied to the function prototype to specify which registers are "clob-
bered" by the assembly function, that is, which registers may have
different values before and after the function call. Consider for example an
simple assembly function to add two integers and mask the result to fit
into 8 bits:
_add_mask:
AY1 = DM(I4 +
AX1 = DM(I4 +
AY0 =
AR = AX1 + AY1;
RTS (DB);
AR = AR AND AY0;
AX1 = AR;
._add_mask.end
Clearly the function does not modify the majority of the scratch registers
available and thus these could instead be used as call-preserved registers.
In this way fewer spills to the stack would be needed in the caller function.
Using the prototype
#pragma regs_clobbered "AX1, AY0, AY1, AR,
int add_mask(int, int);
Good: uses
VisualDSP++ 3.5 C/C++ Compiler and Library Manual
for ADSP-219x DSPs
pragma is a useful way to improve the performance
1);
2);
255;
to increase call-preserved register set.
regs_clobbered
pragma may be
regs_clobbered
ASTAT"
2-33
Need help?
Do you have a question about the VISUALDSP++ 3.5 and is the answer not in the manual?
Questions and answers