C/C++ Compiler Language Extensions
int i;
for (i = 0; i < n; i++)
array[i % 10] += incr;
}
The compiler will recognize that the "
cular reference, and will use a circular buffer if possible.
There are cases where the compiler will not be able to verify that the mem-
ory access is always within the bounds of the buffer. The compiler is
conservative in such cases, and does not generate circular buffer accesses.
The compiler can be instructed to still generate circular buffer accesses
even in such cases, by specifying
The compiler also provides built-in functions which can explicitly gener-
ate circular buffer accesses, subject to available hardware resources. The
built-in functions provide circular indexing, and circular pointer refer-
ences. Both built-in functions are defined in the
Circular Buffer Increment of an Index
The following operation performs a circular buffer increment of an index.
int __builtin_circindex(int index, int incr, unsigned int nitems);
The operation is equivalent to:
index += incr;
if (index < 0)
index += nitems;
else if (index >= nitems)
index -= nitems;
An example of this built-in function is:
void func(int *array, int n, int incr, int len)
{
int i, idx = 0;
for (i = 0; i < n; i++) {
1-104
"-force-circbuf" on page
VisualDSP++ 3.5 C/C++ Compiler and Library Manual
" expression is a cir-
array[i % 10]
builtins.h
for ADSP-219x DSPs
1-27.
header file.
Need help?
Do you have a question about the VISUALDSP++ 3.5 and is the answer not in the manual?
Questions and answers