Motorola once sc140 Manuale Utente

Pagina di 40
Compiler Support on StarCore
12
Introduction to the SC140 Tools
To understand how global optimization makes best use of available information, perform these steps:
6. Recompile the application with 
-S
 option (Stop After Compilation) and with the local optimization: 
ccsc100 -Ot2 Ex3_main.c Ex3_prod.c -S
.
7. Rename the 
.sl
 files as 
Ex3_main1.sl
 and 
Ex3_prod1.sl
.
8. Open the files to see what the compiler has produced.
9. Enable global optimization: 
ccsc100 -Ot2 -Og Ex3_main.c Ex3_prod.c -S
.
10. Open 
Ex3_main.sl 
to see what the compiler has produced.
Since the compiler has all information on the application, it optimizes the application further than with 
local optimization. The compiler avoids calling the function by in-lining the function into the main 
code (as shown in 
Ex3_main.sl
). Therefore, it eliminates the cycle overhead associated with 
jumping to and returning from the function and passing the parameters to the functions.
Congratulations, you have completed Exercise 3.
4   
Memory Alignment Exercise
The memory alignment exercise shows the usage of wide data moves and the necessary alignments for 
performing these moves. The SC140 memory has byte granularity (as represented in Figure 7). Two 
arithmetic address units (AAUs) transfer the data from memory to the 4 ALUs (and vice versa) via two 
64-bit data buses. Each data bus allows the transfer of up to eight bytes from memory to the data registers 
in one cycle (and vice versa). 
If the compiler must generate the wide data move instructions available in the StarCore instruction 
set—such as move.2w, move.2f, move.4w, and so on—data must be correctly aligned in memory. This is 
due to the way the address and data buses operate for multi-byte accesses in the StarCore architecture. The 
compiler does not generate wide data move instructions if alignment is not guaranteed. However, if a 
function is implemented in assembly language and uses wide data move instructions, you must ensure that 
the data is aligned on the appropriate boundary. Otherwise, the wrong data is transferred.
Figure 7.   Memory Granularity
Good To Know
Global optimization requires a longer compilation 
time than local optimization.
Global optimization further optimizes the application 
speed.
P:0x00 
P:0x10 
....
AB
FF
EE
DD
CC
BB
AA
BC
8 bytes
P:0x08 
CD
AB
89
67
45
23
01
EF
8 bytes