#pragma reg_killed_by

Category

Optimization and tuning

Purpose

Specifies registers that may be altered by functions specified by #pragma mc_func.

Ordinarily, code generated for functions specified by #pragma mc_func may alter any or all volatile registers available on your system. You can use #pragma reg_killed_by to explicitly list a specific set of volatile registers to be altered by such functions. Registers not in this list will not be altered.

Syntax

Read syntax diagramSkip visual syntax diagram
                                       .-,------------------------------.   
                                       V                                |   
>>-#--pragma--reg_killed_by--function----+----------------------------+-+-><
                                         '-register -+--------------+-'     
                                                     '- ---register-'       

Parameters

function
The name of a function previously defined using the #pragma mc_func directive.
register
The symbolic name(s) of either a single register or a range of registers to be altered by the named function. The symbolic name must be a valid register name on the target platform. Valid registers are:
cr0, cr1, and cr5 to cr7
Condition registers
ctr
Count register
gr0 and gr3 to gr12
General purpose registers
fp0 to fp13
Floating-point registers
fsr
Floating-point and status control register
lr
Link register
vr0 to vr31
Vector registers (on selected processors only)
xer
Fixed-point exception register

You can identify a range of registers by providing the symbolic names of both starting and ending registers, separated by a dash.

If no register is specified, no volatile registers will be killed by the named function.

Examples

The following example shows how to use #pragma reg_killed_by to list a specific set of volatile registers to be used by the function defined by #pragma mc_func.

int add_logical(int, int);
#pragma mc_func add_logical {"7c632014" "7c630194"}
                /*   addc       r3 <- r3, r4           */
                /*   addze      r3 <- r3, carry bit    */

#pragma reg_killed_by add_logical gr3, xer
                /* only gpr3 and the xer are altered by this function */


main() {

      int i,j,k;

      i = 4;
      k = -4;
      j = add_logical(i,k);
      printf("\n\nresult = %d\n\n",j);
}

Related information