Pragmas
the compiler is told which registers are modified by a call to the
function. The registers not specified by the pragma are assumed to pre-
serve their values across such a call and the compiler may use these spare
registers to its advantage when optimizing the call sites.
The pragma is also powerful when all of the source code is written in C. In
the above example, a C implementation might be:
int add_mask(int a, int b) {
return ((a+b)&255);
}
Bad: function thought to clobber entire volatile register set.
Since this function will not need many registers when compiled, it can be
defined using:
#pragma regs_clobbered "AX1, AY0, AY1, AR, M7, CCset"
int add_mask(int a, int b) {
return ((a+b)&255);
}
Good: function compiled to preserve most registers.
to ensure that any other registers aside from
condition codes will not be modified by the function. If any other regis-
ters are used in the compilation of the function, they will be saved and
restored during the function prologue and epilogue.
In general, it is not very helpful to specify any of the condition codes as
call-preserved as they are difficult to save and restore and are usually clob-
bered by any function. Moreover, it is usually of limited benefit to be able
to keep them live across a function call. Therefore, it is better to use
(all condition codes) rather than
more information, refer to
page
1-130.
2-34
ASTAT
"#pragma regs_clobbered string" on
VisualDSP++ 3.5 C/C++ Compiler and Library Manual
,
,
AX1
AY0
AY1
in the clobbered set above. For
for ADSP-219x DSPs
add_mask
,
,
and the
AR
M7
CCset
Need help?
Do you have a question about the VISUALDSP++ 3.5 and is the answer not in the manual?