System Support Built-In Functions - Analog Devices VISUALDSP++ 3.5 Manual

C/c++ compiler and library for adsp-219x processors
Hide thumbs Also See for VISUALDSP++ 3.5:
Table of Contents

Advertisement

Using Built-In Functions in Code Optimization
In the example code, the compiler recognizes this idiom and replaces the
multiply followed by shift with a fractional multiply. In more complicated
cases, where perhaps the multiply is further separated from the shift, the
compiler may not detect the possibility of using a fractional multiply.
The recommended coding style is to use built-in functions. In the follow-
ing example, a builtin is used to multiply fractional 16-bit data.
#include <math.h>
fract32 dot_product(fract16 *a, fract16 *b) {
int i;
fract32 sum=0;
for (i=0; i<100; i++) {
/* this line is performance critical */
sum += __builtin_mult_fr1x32(a[i],b[i]);
}
return sum;
}
Good: uses builtins to implement fractional multiplication.
Note that the
fract16
merely
typedefs
include files. The compiler does not have any in-built knowledge of these
types and treats them exactly as the integer types that they are

System Support Built-In Functions

Built-in functions are also provided to perform low-level system manage-
ment, in particular for the manipulation of system registers (defined in
). It is usually better to use these built-in functions rather than
sysreg.h
inline
statements. The built-in functions cause the compiler to gener-
asm
ate efficient inline instructions and their use often results in better
optimization of the surrounding code at the point where they are used.
Using builtins will also usually result in improved code-readability. For
more information on built-in functions supported by the compiler, refer
to
"Compiler Built-In Functions" on page
2-26
and
fract32
to C integer types used by convention in standard
VisualDSP++ 3.5 C/C++ Compiler and Library Manual
types used in the example above are
1-94.
for ADSP-219x DSPs
to.
typedefed

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the VISUALDSP++ 3.5 and is the answer not in the manual?

Questions and answers

Related Products for Analog Devices VISUALDSP++ 3.5

Table of Contents