SPRU514Z July 2001 – October 2023 SM320F28335-EP
Post-link optimization reduces the difficulty of managing the Data Page (DP) register by removing redundant DP loads. It does this by tracking the current value of the DP and determining whether the address in a MOV DP,#address instruction is located on the same 64-word page to which the DP is currently pointing. If the address can be accessed using the current DP value, the instruction is redundant and can be removed. For example, consider the following code segment:
MOVZ DP,#name1
ADD @name1,#10
MOVZ DP,#name2
ADD @name2,#10
If name1 and name2 are linked to the same page, the post-link optimizer determines that loading DP with the address of name2 is not necessary, and it comments out the redundant load.
MOVZ DP,#name1
ADD @name1,#10
; <<REDUNDANT>> MOVZ DP,#name2
ADD @name2,#10
This optimization can be used on C files as well. Even though the compiler manages the DP for all global variable references that are defined within a module, it conservatively emits DP loads for any references to global variables that are externally defined. Using the post-link optimizer can help reduce the number of DP loads in these instances.
Additionally, the --map_file linker option can be used to generate a listing of symbols sorted by data page to assist with data layout and DP load reduction. For more information, refer to the Linker Description chapter in the TMS320C28x Assembly Language Tools User's Guide.