SPRU514Z July 2001 – October 2023 SM320F28335-EP
You control the output of the interlist feature when compiling with optimization (the --opt_level=n or -On option) with the --optimizer_interlist and --c_src_interlist options.
When you use the --optimizer_interlist option with optimization, the interlist feature does not run as a separate pass. Instead, the compiler inserts comments into the code, indicating how the compiler has rearranged and optimized the code. These comments appear in the assembly language file as comments starting with ;**. The C/C++ source code is not interlisted, unless you use the --c_src_interlist option also.
The interlist feature can affect optimized code because it might prevent some optimization from crossing C/C++ statement boundaries. Optimization makes normal source interlisting impractical, because the compiler extensively rearranges your program. Therefore, when you use the --optimizer_interlist option, the compiler writes reconstructed C/C++ statements.
When you use the --c_src_interlist and --optimizer_interlist options with optimization, the compiler inserts its comments and the interlist feature runs before the assembler, merging the original C/C++ source into the assembly file. For example, suppose the following C code is compiled with optimization (--opt_level=2) and --optimizer_interlist options:
int copy (char *str, const char *s, int n)
{
int i;
for (i = 0; i < n; i ++)
*str++ = *s++;
}
The assembly file contains compiler comments interlisted with assembly code.
;***************************************************************
;* FNAME: _copy FR SIZE: 0 *
;* FUNCTION ENVIRONMENT *
;* FUNCTION PROPERTIES *
;* 0 Parameter, 0 Auto, 0 SOE *
;***************************************************************
_copy:
;*** 6 ----------------------- if ( n <= 0 ) goto g4;
CMPB AL,#0 ; |6|
B L2,LEQ ; |6|
; branch occurs ; |6|
;*** ----------------------- #pragma MUST_ITERATE(1, 4294967295, 1)
:*** ----------------------- L$1 = n-1;
ADDB AL,#-1
MOVZ AR6,AL
L1:
;*** -----------------------g3:
;*** 7 ----------------------- *str++ = *s++;
;*** 7 ----------------------- if ( (--L$1) != (-1) ) goto g3;
MOV AL,*XAR5++ ; |7|
MOV *XAR4++,AL ; |7|
BANZ L1,AR6--
; branch occurs ; |7|
;*** -----------------------g4:
;*** ----------------------- return;
L2:
LRETR
; return occurs
If you add the --c_src_interlist option (compile with --opt_level=2, --c_src_interlist, and --optimizer_interlist), the assembly file contains compiler comments and C source interlisted with assembly code.
;----------------------------------------------------------------------
; 2 | int copy (char *str, const char *s, int n)
;----------------------------------------------------------------------
;***************************************************************
;* FNAME: _copy FR SIZE: 0 *
;* *
;* FUNCTION ENVIRONMENT *
;* *
;* FUNCTION PROPERTIES *
;* FUNCTION PROPERTIES *
;* 0 Parameter, 0 Auto, 0 SOE *
;***************************************************************
_copy
;* AR4 assigned to _str
;* AR5 assigned to _s
;* AL assigned to _n
;* AL assigned to _n
;* AR5 assigned to _s
;* AR4 assigned to _str
;* AR6 assigned to L$1
;*** 6 ----------------------- if ( n <= 0 ) goto g4;
;----------------------------------------------------------------------
; 4 | int i;
;----------------------------------------------------------------------
;----------------------------------------------------------------------
; 6 | for (i = 0; i < n; i++)
;----------------------------------------------------------------------
CMPB AL,#0 ; |6|
B L2,LEQ ; |6|
; branch occurs ; |6|
;*** ----------------------- #pragma MUST_ITERATE(1, 4294967295, 1)
:*** ----------------------- L$1 = n-1;
ADDB AL,#-1
MOVZ AR6,AL
NOP
L1:
;*** 7 ----------------------- *str++ = *s++;
;*** 7 ----------------------- if ( (--L$1) != (-1) ) goto g3;
;----------------------------------------------------------------------
; 7 | *str++ = *s++;
;----------------------------------------------------------------------
MOV AL,*XAR5++ ; |7|
MOV *XAR4++,AL ; |7|
BANZ L1,AR6--
; branch occurs ; |7|
;*** -----------------------g4:
;*** ----------------------- return;
L2:
LRETR
; return occurs