Chapter 12. Scalar Optimization #pragma Directives

Table 12-1 lists the #pragma directives discussed in this chapter, along with a short description of each and the compiler versions in which the directive is supported.

Table 12-1. Scalar Optimization #pragma Directives

#pragma

Short Description

Compiler Versions

#pragma mips_frequency_hint

Specifies the expected frequency of execution so that cord2 can move exception code and initialization code into separate pages to minimize working set size.

7.2 and later

#pragma section_gp (in Chapter 7, “Loader Information #pragma Directives”)

Causes an object to be placed in a gp_relative section.

7.2 and later

#pragma section_non_gp (in Chapter 7, “Loader Information #pragma Directives”)

Keeps an object from being placed in a gp_relative section.

7.2 and later

#pragma unroll (in Chapter 8, “Loop Nest Optimization #pragma Directives”)

Suggests to the compiler that a specified number of copies of the loop body be added to the inner loop. If the loop following this directive is an inner loop, then it indicates standard unrolling. If the loop following this directive is not innermost, then outer loop unrolling (unroll and jam) is performed.

7.2 and later


#pragma mips_frequency_hint

This directive allows you to specify the expected frequency of execution of the named function so the compiler can move exception code and initialization code into separate pages to minimize working-set size.

The syntax of #pragma mips_frequency_hint is as follows:

#pragma mips_frequency_hint [NEVER|INIT]  [function_name]

#pragma mips_frequency_hint is not currently supported in C++, except for symbols marked extern “C”.

This directive provides a mechanism for you to specify information about execution frequency for certain regions in the code. You can provide the following frequency specifications:

  • NEVER: this region of code is never or rarely executed. The compiler might move this region of the code away from the normal path. This movement might either be at the end of the procedure or at some point to an entirely separate section.

  • INIT: this region of code is executed only during initialization or startup of the program. The compiler might try to put all regions under “INIT” together to provide better locality during startup of a program.

You can use this directive in two ways:

  1. You can specify it with a function declaration. The directive then applies everywhere the function is called.

    extern void Error_Routine();
    #pragma mips_frequency_hint NEVER Error_Routine


    Note: In this case, the directive must appear after the function declaration.


  2. You can specify it without a function declaration. In this case, you can place the directive anywhere in the body of a procedure. It then applies to the statement directly following the directive.

    if (some_condition)
    {
    #pragma mips_frequency_hint NEVER
    Error_Routine ();
    ...
    }


Caution: This is directive is supported on compiler version 7.2 only, and it does not work for -o32 because it requires an ELF object file with .MIPS.content sections.