Digital Signal Processing Reference
In-Depth Information
2.2
Compiler and Language Extensions
In the performance-critical DSP environment both the compiler and the C pro-
gramming language itself are frequently extended to narrow the gap between the
high-level language and the target processor and, thus, enabling the compiler to
generate “better” code. Programmers can use these extensions to convey extra
information to the compiler. Thereby the compiler is directed to make explicit
use of specific processor features such as specialized instructions or dual memory
banks. Compiler-known functions extend the compiler with special functions and
are available to the programmer as convenient shortcuts to custom DSP operations
provided by the specific target processor. On the other hand, DSP-C and Embedded
C are extensions to the ISO-C language standard [ 20 ] and provide the programmer
with new, DSP-specific language keywords. This later approach maintains a certain
degree of portability and readability of the code while making use of DSP-specific
hardware extensions to increase code efficiency.
2.2.1
Compiler-Known Functions
Compiler-known functions (CKFs), sometimes also called intrinsic functions, are
function calls that are not mapped to regular function calls by the compiler, but
are directly replaced by one or more assembly instructions. CKFs enhance the
readability of the C code while at the same time they provide a convenient way
of directing the compiler to explicitly emit a particular sequence of instructions.
CKFs are useful in cases where the compiler is known to not generate the desired
instruction, e.g. because its pattern is not tree shaped and does not fit into the usual
tree covering based instruction selection algorithm employed by the compiler, or the
programmer wants to exercise specific control over the code generation process for
performance reasons.
For instance, the compiler for the NXP TriMedia TM5250 processor defines a
CKF ifir16 for computing the signed sum of products of signed 16-bit halfwords.
This operation is useful in implementing complex arithmetic, but results in several
assembly instructions when implemented in “plain” C rather than a CKF. The NXP
compiler, however, has knowledge about this special function and maps what looks
like an ordinary function call to ifir16 directly to a single assembly instruction
of the same name.
CKFs require a detailed understanding of the target processor by the pro-
grammer and code written using CKFs is machine-dependent. Portability can be
re-established, however, by providing a suitable set of simulation functions (written
in “plain” ISO-C) for the CKFs that are less efficient, but functionally equivalent to
their machine-specific counterparts.
Search WWH ::




Custom Search