本帖最后由 再玩剁手 于 2023-4-27 11:04 编辑
C2000 Code Generation Tools v22.6.0.LTS Release Notes
C2000 Code Generation Tools v22.6.0.LTS
New Features:
New option --fp_single_precision_constant treats unsuffixed floating point constants as 32-bit
New option --fp_single_precision_constant treats unsuffixed floating-point constants as single precision instead of implicitly converting them to double-precision constants. Interrupt save/restore efficiency improvement
The C2000 compiler now only saves/restores any registers that were used in an interrupt service routine (ISR). Additionally, if an ISR makes function calls, then all save-on-call (SoC) registers will get saved/restored. For FPU compilations, the RB register is saved/restored for all low priority ISRs, however, for high priority ISRs, the RB register is only saved/restored if the ISR may use an RPTB instruction. The compiler user guide states:
“If a C/C++ interrupt routine does not call any other functions, only those registers that the interrupt handler uses are saved and restored”
However, prior to this update, above has not been the case since at least release 6.4 and the actual behavior has been to save/restore all SoC registers as long as any single SoC register was used.
Performance improvements CLA
CLA support enabled for generating MMACF32||MMOV32
The CLA compiler has a new feature for generating parallel MMACF32 with MMOV32 instructions. Generating MMACF32||MMOV32 requires --opt_level=2 or higher and loop unrolling is recommneded for creating more opportunities for the parallel MMACF32 with MMOV32. For example:
- // result, buff[], and coef[] are float
- interrupt void Cla1Task1 ( void )
- {
- result = 0.0f;
- int16_t i;
- #pragma UNROLL(20)
- for(i = 20; i > 0; i–)
- {
- buff<i> = buff[i-1];
- result += coef<i> * buff<i>;
- }
- result += coef[0] * buff[0];
- }</i></i></i>
复制代码
CLA MRn loads of unsigned short are more efficient
The CLA compiler now generates more efficient loads of unsigned short variables to the 32-bit MRn register. Previously the compiler generated below including the redundant zero extending shifts:
- {
- // unsigned a,b;
- // a = b;
- MMOVZ16 MR0,@b
- MLSL32 MR0,#16
- MLSR32 MR0,#16
- }
复制代码
The CLA compiler instead generates only below which already zero extends:
- {
- // unsigned a,b;
- // a = b;
- MMOVZ16 MR0,@b
- }
复制代码
Performance improvements C28
Improvements in reducing register spilling
The C2000 compiler has a new feature for reducing register spilling. During register allocation (selection of registers), if no registers are available, then the compiler must spill a register to memory (or another register) in order to make it available for register allocation.
A new optimization pass has been enabled for compilations with --opt_level=2 or higher and --float_support=fpu32/fpu64. If register spilling is detected, the compiler will generate a new instruction schedule to alleviate register pressure (shorten register use lifetimes) which should in turn reduce register spilling. Keep global float/double variables in registers
The C2000 compiler has a new optimization that will attempt to keep global float/double variables in registers if the device has fpu register support. As a simple example, prior to this optimization, below loop:
f- loat flt;
- for(i=0;i<2000;i++)
- {
- flt = flt + flt;
- }
复制代码
would generate this assembly that loads/stores the float variable from memory during each iteration (with --opt_level=2):
- MOVL XAR6,#1999
- loop:
- MOVW DP,#flt
- MOV32 R0H,@flt
- MOV32 R1H,@flt
- ADDF32 R0H,R0H,R1H
- NOP
- MOV32 @flt,R0H
- BANZ loop,AR6
复制代码
— which now is improved to this sequence that keeps the float variable in R2H during the loop:
- MOVW DP,#flt
- MOVL XAR6,#1999
- MOV32 R2H,@flt
- loop:
- ADDF32 R2H,R2H,R2H
- BANZ loop,AR6—
复制代码
If-conversion improvements
The current if-conversion optimizations for the C2000 compiler have been extended with below additional use cases.
This sequence with --opt_level=off,0,1: - extern float f1, f2;
- float foo(float cond)
- {
- return cond > 1.0f ? f1 : f2;
- }
- ||foo||:
- CMPF32 R0H,#16256
- MOVST0 ZF, NF
- B ||label1||,LEQ
- MOVW DP,#||f1||
- MOV32 R0H,@||f1||
- B ||label2||,UNC
- ||label1||:
- MOVW DP,#||f2||
- MOV32 R0H,@||f2||
- ||label2||:
- LRETR
复制代码
with --opt_level=2,3,4 is now generated without the branches:- ||foo||:
- CMPF32 R0H,#16256
- MOVW DP,#||f1||
- MOV32 R0H,@||f1||,GT
- MOVW DP,#||f2||
- MOV32 R0H,@||f2||,LEQ
- LRETR
复制代码
This sequence: - MOVL XAR4,#||t||
- TBIT *+XAR4[0],#1
- MOVB XAR0,#8,TC
- B ||label||,TC
- MOVB XAR0,#0
- label:
复制代码
is instead generated without the branch: - MOVL XAR4,#||t||
- MOVB XAR0,#0
- TBIT *+XAR4[0],#1
- MOVB XAR0,#8,TC
复制代码
And this sequence:
- TBIT *+XAR5[0],#2
- B label,NTC
- MOV AH,AR0
- ORB AH,#0x04
- MOVZ AR0,AH
- label:
复制代码
is instead generated without the branch:- TBIT *+XAR5[0],#2
- MOV AH,AR0
- ORB AH,#0x04
- MOV AR0,AH,TC
复制代码
Improved loads of 16-bit constants to ACC register
Below accumulator load of 16-bit constants:
- MOVL XAR4,#256
- MOVL ACC,XAR4
复制代码
is now directly loaded to the ACC register:
RTS library routine fmodf() now has faster tmu relaxed implementation using __fmodf intrinsic
The current RTS library support for fmodf() has been extended with a faster tmu implementation using new intrinsic __fmodf().
Below intrinsic is available with option --tmu_support=tmu0,tmu1. - float __fmodf(float x, float y); /* return fmodf(x,y) */
复制代码
If the user specifies --fp_mode=relaxed in combination with the --tmu_support=tmu0,tmu1 option in the compiler command line, then the following RTS function will make use of the new __fmodf intrinsic:- float fmodf(float x, float y);
复制代码
Hex tool: new options --boot_align_sect and --boot_block_size=size
- --boot_align_sect
New option --boot_align_sect will cause the hex tool to adjust the default boot record limit size based on section alignment (for alignment > 1). For example, if an output section has ALIGN(16), then the boot record size will be adjusted from default value of 0xFFFE to 0xFFF0. - --boot_block_size=size
New option --boot_block_size=size allows overriding the hex utility default boot block size. (ARM default is 0xFFFF which is not supported by C28 FLASH API).
For use with the C28 FLASH API and the C28 on-chip bootloader:
c28 hex boot files: hex2000 current-boot-options –boot_align_sect
arm hex boot files: armhex current-boot-options –boot_align_sect –boot_block_size=0xFFFE
|