This section documents some of the commonly used compiler options. For details on using the compiler, refer to TMS320C28x Optimizing C/C++ Compiler User’s Guide, Chapter 2, Using the C/C++ Compiler.

2.3.1. ABI

The ABI is selected through the –abi option as follows:

  • COFF ABI (--abi=coffabi). This is the default.

  • EABI (--abi=eabi). Use this option to select the C28x Embedded Application Binary Interface (EABI).

Refer to section Application Binary Interface (ABI) for details.

2.3.2. Enable FPU

On supported C28x CPUs, use the --float_support[=fpu32|fpu64] to enable 32-bit or 64-bit hardware floating-point support. FPU64 is supported only when using EABI.

Note

It is beneficial to enable the FPU even if the application does not use floating-point. This enables the compiler to leverage instructions such as the Repeat Block (RPTB) to significantly reduce branching overhead in certain loops.

2.3.3. Enable TMU

On supported C28x CPUs, use the ----tmu_support[=tmu0|tmu1] to enable support for the Trigonometric Math Unit (TMU). Using this option automatically enables FPU support (as with the --float_support=fpu32 option). When TMU support is enabled, intrinsics are available to perform trigonometric instructions on the TMU. In relaxed floating point mode, RTS library calls are replaced with the corresponding TMU hardware instructions for the following floating point operations: floating point division, sqrt, sin, cos, atan, and atan2. Additionally, if the --tmu_support=tmu1 option is used with -- fp_mode=relaxed, special versions of the following 32-bit RTS math functions are used: exp2f(), espf(), log2f(), logf(), and powf().

2.3.4. Enable IDIV support

On supported C28x CPUs, use the --idiv_support=idiv0 to enable support for fast integer division using hardware extensions to provide a set of instructions to accelerate integer division. When this option is enabled, the built-in integer division and modulo operators (“/” and “%”) use the appropriate faster instructions.

For details on enabling FPU, TMU and IDIV, refer to the TMS320C28x Optimizing C/C++ Compiler User’s Guide Section 2.3.4 Run-Time Model Options.

2.3.5. Unified memory model

Unified memory model means that any memory block can be used as either program memory or data memory. All memory blocks including SARAM, flash, ROM, OTP and XINTF memory is unified on the C28x MCUs. Peripheral registers are typically only mapped to data space.

If the applications memory map is configured as a single unified space, specifying unified memory model in the build options (--unified_memory) is important because it allows the compiler to generate efficient instructions for memcpy calls and structure assignments.

Even under unified memory, memory for some peripherals and some RAM associated with those peripherals is allocated only in data memory. If --unified_memory is enabled, program memory address access to specific symbols such as peripheral registers can be prevented by declaring those symbols as volatile.

Refer to Data allocation for instructions with two memory operands for an example of using --unified_memory to enable the compiler to generate the MAC instruction.

2.3.6. Enable debugging

During initial development, it is recommended to use the following options for debuggability:

  • -g (--symdebug:dwarf)

  • --opt_level=off

Setting --opt_level=off improves the debug experience. In general, the higher the level of optimization that is applied, the harder it is to debug the program. This is because higher levels of optimization enable more transformations and apply to broader granularities or scopes of the program. Optimizations at levels 0 and 1 are applied to individual statements or blocks of code within functions, level 2 enables optimizations across blocks of code within a function, level 3 enables optimizations across functions within a file, and level 4 enables optimizations across files. Since transformations that occur at higher levels are usually more widespread, it is harder for the debugger to map the resulting code to the original source program.

For details, refer to the TI E2E blog on Debugging and Optimization