#pragma reg_killed_by

Description

The #pragma reg_killed_by directive specifies a set of volatile registers that may be altered (killed) by the specified function. This pragma can only be used on functions that are defined using #pragma mc_func.

Syntax

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

where:

function The function previously defined using the #pragma mc_func.
regid The symbolic name(s) of either a single register or a range of registers to be altered by the named function. A range of registers is identified by providing the symbolic names of both starting and ending registers, separated by a dash. If no registers are specified, no registers will be altered by the specified function.

The symbolic name is made up of two parts. The first part is the register class name, specified using a sequence of one or more characters in the range of "a" to "z" and/or "A" to "Z".

The second part is a integral number in the range of unsigned int. This number identifies a specific register number within a register class. Some register classes do not require that a register number be specified, and an error will result if you try to do so.

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

Registers
Class and [Register numbers] Description and usage
ctr Count register (CTR)
cr[0-7] Condition register (CR)
  • Each register in this class is one of the 4-bit fields in the condition register.
  • Of the 8 CR fields, only cr0, cr1, and cr5-cr7 can be specified by #pragma reg_killed_by.
fp[0-31] Floating point registers (FPR)
  • Of the 32 machine registers, only fp0-fp13 can be specified by #pragma reg_killed_by.
fs Floating point status and control register (FPSCR)
lr Link register (LR)
mq MQ register (MQ)
gr[0-31] General purpose registers (GPR)
  • Of the 32 machine registers, only gr0 and gr3-gr12 can be specified by #pragma reg_killed_by.
vr[0-31] Vector registers (Altivec processors only)
xer Fixed point exception (XER)

Notes

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.

Registers specified by regid must meet the following requirements:

If any of these requirements are not met, an error is issued and the pragma is ignored.

Example

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