SLAU132Y September 2004 – June 2021
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.
main:
;* -----------------------------------------------------------------------*
SUB.W #2,SP
;** 5 ------------------------- printf((const unsigned char *)"Hello, world\n");
MOV.W #$C$SL1+0,0(SP) ; |5|
CALL #printf ; |5|
; |5|
;** 6 ------------------------- return 0;
MOV.W #0,r12 ; |6|
ADD.W #2,SP
RET
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.
main:
;* ----------------------------------------------------------------------------*
SUB.W #2,SP
;** 5 ------------------------- printf((const unsigned char *)"Hello, world\n");
;------------------------------------------------------------------------
; 5 | printf ("Hello, world\n");
;------------------------------------------------------------------------
MOV.W #$C$SL1+0,0(SP) ; |5|
CALL #printf ; |5|
; |5|
;** 6 ------------------------- return 0;
;------------------------------------------------------------------------
; 6 | return 0;
;------------------------------------------------------------------------
MOV.W #0,r12 ; |6|
ADD.W #2,SP
RET