By default, the Code Composer Studio (CCS) compiler allows dual-state interworking between functions. However, the compiler allows the user to alter the level of support to meet the specific needs.
In dual-state interworking, it is the called function’s responsibility to handle the proper state changes required by the calling function. It is the calling function’s responsibility to handle the proper state changes required to indirectly call a function (call it by address). Therefore, a function supports dual-state interworking if it provides the capability for functions requiring a state change to directly call the function (call it by name) and provides the mechanism to indirectly call functions involving state changes.
If a function does not support dual-state interworking, it cannot be called by functions requiring a state change and cannot indirectly call functions that support dual-state interworking. Regardless of whether a function supports dual-state interworking or not, it can directly or indirectly call certain functions, as summarized below:
- Directly call a function in the same state
- Directly call a function in a different state if that function supports dual-state interworking
- Indirectly call a function in the same state if that function does not support dual-state interworking
Given this definition of dual-state support, the CCS compiler offers three levels of support. The following table offers guidelines to determine the best level of support to use for the user’s code.
If the code... | Use this level of support |
---|
requires no state changes and has frequent indirect calls | None |
requires few state changes | Default |
requires several state changes | Optimized |
Detailed information about each level of support is provided below:
- None:
Dual-state interworking is disabled. This level is invoked with the −md shell option. Functions with this support can directly call the following functions:
- Functions complied in the same state
- Functions in a different state that support dual-state interworking
Functions with this support level can indirectly call only functions that do not require a state change and do not support dual-state interworking. Because functions with this support level do not provide dual-state interworking, they cannot be called by a function requiring a state change.
This support level is used if user does not require dual-state interworking, has frequent indirect calls, and cannot tolerate the additional code size or speed incurred by the indirect calls supporting dual-state interworking. When a program does not require any state changes, the only difference between specifying no support and default support is that indirect calls are more complex in the default support level. - Default:
Full dual-state interworking is supported in this level. For each function that supports full dual-state interworking, the compiler generates code that allows functions requiring a state change to call the function, whether it is ever used or not. This code is placed in a different section from the section the actual function is in. If the linker determines that this code is never referenced, it does not link it into the final executable image. However, the mechanism used with indirect calls to support dual-state interworking is integrated into the function and cannot be removed by the linker, even if the linker determines that the mechanism is not needed. - Optimized:
Optimized dual-state interworking provides no additional functionality over the default level but optimizes the dual-state support code (in terms of code size and execution speed) for the case where a state change is required. It does this optimization by integrating the support into the function. Use the optimized level of support only when a majority of the calls to this function require a state change. Even if the dual-state support code is never used, the linker cannot remove the code because it is integrated into the function. To specify this level of support, use the DUAL_STATE pragma. See section 5.7.2, The DUAL_STATE Pragma, on page 5-15 of TMS470R1x Optimizing C/C++ Compiler User's Guide for more information (SPNU151).