3.3.1.2 Migrating CLAmath.h Functions and
Intrinsics
The CLA compiler does not support
math.h. A separate file CLAmath.h is used, which contains external references to
functions/variables in the C2000Ware CLAmath library. These are hand optimized
CLA assembly routines for specific operations (trig, div, sqrt, isqrt, exp,
log). It also contains function redefinitions/mappings for code portability from
C28 to CLA, such as:
Mapping specific math.h
functions and TMU intrinsics to CLA math library functions mentioned
above. For example, if C28 code contains __cos (corresponding to the TMU
instruction) or cosf, it will migrate without any updates to CLA because
CLAmath.h maps __cos and cosf to CLAcos (in the CLAMath library) or
CLAcos_inline (in CLAmath.h).
So if user CLA
code contains __cos, migrating to C29 will be similar to
migrating C28 intrinsics to C29, as discussed in the C28-C29
source code migration section.
The C29
compiler has a tool called c29clang-tidy which checks
for use of C28 intrinsics and suggest alternatives if
available, which is discussed here (under
c29migration-c28-builtins). It is applicable here as
well.
If it contains
cosf, migrating to C29 does not require any changes.
However, if it
contains CLAcos or CLAcos_inline, then the user needs to change
all these calls to cosf. A mapping header file to assist in
migration of CLAMath functions is planned.
Mapping specific math.h
functions and C28+FPU intrinsics to CLA intrinsics. For example, if C28
code contains __fmax (corresponding to the FPU instruction) or fmaxf, it
will migrate without any updates to CLA because CLAmath.h maps __fmax
and fmaxf to __mmaxf32 (the CLA intrinsic).
So if user CLA
code contains __fmax, migrating to C29 will be similar to
migrating C28 intrinsics to C29, as discussed in the C28-C29
source code migration section.
The C29
compiler has a tool called c29clang-tidy which checks
for use of C28 intrinsics and suggest alternatives if
available, which is discussed here (under
c29migration-c28-builtins). It is applicable here as
well.
If it contains
fmaxf, migrating to C29 does not require any changes.
However, if it
contains __mmaxf32, then the user needs to change all these
calls to fmaxf. c29clang-tidy extension to check for CLA
intrinsics is planned.
If user code contains CLA
intrinsics that do not map to a corresponding C28 intrinsic (for
example, __mgeq, __mgequ, __mgt, __mgtu, __mleq, __mlequ, __mlt, __mltu,
__mdebugstop), user code needs to be manually updated to fix them.
c29clang-tidy extension to check for CLA intrinsics is
planned.