User Tools

Site Tools


optimize_pragmas_1.htm
Navigation:  Advanced Topics > Legacy Project System Reference >====== Optimize #pragmas ====== Previous pageReturn to chapter overviewNext page

#pragmas with the class name optimize control optimizations performed by the SoftVelocity code generator. By default, all optimizations are enabled. Turning off an optimization will result in poorer code quality, and is unlikely to have a significant impact on compile times.

The following optimize #pragmas are available:

#pragma optimize(alias ⇒ on | off)

#pragma optimize(const ⇒ on | off)

#pragma optimize(copro ⇒ 87 | 287 | 387)

#pragma optimize(cpu ⇒ 86 | 286 | 386 | 486)

#pragma optimize(cse ⇒ on | off)

#pragma optimize(jump ⇒ on | off)

#pragma optimize(loop ⇒ on | off)

#pragma optimize(peep_hole ⇒ on | off)

#pragma optimize(regass ⇒ on | off)

#pragma optimize(speed ⇒ on | off)

#pragma optimize(stk_frame ⇒ on | off)

NoteBox.jpg

A pragma can be used in the Project language, C++ code, Modula-2 code, or Clarion code. Some only work in certain places. A 'P' to the right of the pragma indicates it can be used in the Project language, a 'C' indicates it can be used in C++ code, a 'M' indicates it can be used in Modula-2 code, and a 'W' indicates that it can be used in Clarion code (CLW files).

#pragma optimize(cse ⇒ on | off)    cpm

When on, the compiler minimizes evaluation of complete expressions by keeping partial results in a temporary register. The default setting is on.

#pragma optimize(const ⇒ on | off)    cpm

When on, the compiler will hold frequently used constants in registers to produce faster code. The default setting is on.

#pragma optimize(speed ⇒ on | off)    cpmw

When on, SoftVelocity tries to make the code run as fast as possible without regard for the code size. When off, SoftVelocity tries to make the code as small as possible.

A good example of the difference between optimizing for speed and optimizing for space is the use of a for loop. When optimizing for speed, the compiler might use nop instructions to place jump labels inside the for loop on even boundaries. The 80×86 architecture makes this much quicker than odd boundaries, but each nop adds another byte to the code size. This means that when optimizing for space, the compiler eliminates the extra nop instructions. The default setting is on.

#pragma optimize(stk_frame ⇒ on | off)   cpm

When on, the compiler will only make stack frames where required, thus eliminating the need to set up the BP register. This optimization can only be made when all parameters and local variables for a procedure can be held in machine registers.

When off, the compiler always sets up the BP register, thus allowing a complete activation stack listing while debugging. The default setting is on.

#pragma optimize(regass ⇒ on | off)    cpm

When on, the compiler spends time finding the best allocation of registers for variables. This results in fast and tight code but slower compile. The default setting is on.

#pragma optimize(peep_hole ⇒ on| off)   cpm

When on, the compiler performs a variety of machine-code translations, generating smaller and faster code. The default setting is on.

#pragma optimize(jump ⇒ on | off)    cpm

When on, the compiler will rearrange loops to eliminate as many jumps as possible, thus generating faster code. The default setting is on.

#pragma optimize(loop ⇒ on | off)    cpm

When on, the compiler uses the loop depth when eliminating common sub-expressions and performing jump optimizations. The result of this optimization is faster, but potentially larger, code. The default is on.

#pragma optimize(alias ⇒ on | off)    cpm

When on, this allows the compiler to assume that variables in a procedure will not also be used indirectly with a pointer in the same procedure. This assumption is not strictly allowed in ANSI C but is correct for all meaningful programs. The default setting is on.

#pragma optimize(cpu ⇒ 86 | 286 | 386 | 486)  cpmw

This controls the instructions used by the code generator, by declaring the processor to be used. The default is cpu⇒286. Ignored in this release.

#pragma optimize(copro ⇒ 87 | 287 | 387)   cpmw

This controls the instructions used by the code generator, by declaring the math coprocessor to be used. The default is cpu⇒287. Ignored in this release.

optimize_pragmas_1.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1