Miscellaneous built-in functions

Prototype Description
void __alignx(int alignment, const void *address); Informs the compiler that the specified address is aligned at a known compile-time offset. alignment must be a positive constant integer with a value greater than zero and of a power of two.
void __builtin_return_address (unsigned int level); Returns the return address of the current function, or of one of its callers. Where level argument is a constant literal indicating the number of frames to scan up the call stack. The level must range from 0 to 63. A value of 0 yields the return address of the current function, a value of 1 yields the return address of the caller of the current function and so on.
Notes:
  1. When the top of the stack is reached, the function will return 0.
  2. The level must range from 0 to 63, otherwise a warning message will be issued and the compilation will halt.
  3. When functions are inlined, the return address corresponds to that of the function that is returned to.
  4. Compiler optimization may affect expected return value due to introducing extra stack frames or fewer stack frames than expected due to optimizations such as inlining.
void __builtin_frame_address (unsigned int level); Returns the address of the function frame of the current function, or of one of its callers. Where level argument is a constant literal indicating the number of frames to scan up the call stack. The level must range from 0 to 63. A value of 0 yields the return the frame address of the current function, a value of 1 yields the return the frame address of the caller of the current function and so on.
Notes:
  1. When the top of the stack is reached, the function will return 0.
  2. The level must range from 0 to 63, otherwise a warning message will be issued and the compilation will halt.
  3. When functions are inlined, the frame address corresponds to that of the function that is returned to.
  4. Compiler optimization may affect expected return value due to introducing extra stack frames or fewer stack frames than expected due to optimizations such as inlining.
void __fence(void); Acts as a barrier to compiler optimizations that involve code motion, or reordering of machine instructions. Compiler optimizations will not move machine instructions past the location of the __fence call. This construct is useful to guarantee the ordering of instructions in the object code generated by the compiler when optimization is enabled.
unsigned long __mftb(); Move from Time Base

In 32-bit compilation mode, returns the lower word of the time base register, and can be used in conjunction with the__mftbu built-in function to read the entire time base register. In 64-bit mode, returns the entire doubleword time base register.

Note:
It is recommended that you insert the __fence built-in function before and after the __mftb built-in function.

unsigned int __mftbu(); Move from Time Base Upper

In 32-bit compilation mode, returns the upper word of the time base register, and can be used in conjunction with the __mftb built-in function to read the entire time base register. In 64-bit mode, returns the entire doubleword time base register; therefore, separate use of __mftbu is unnecessary.

Note:
It is recommended that you insert the __fence built-in function before and after the __mftbu built-in function.

unsigned long __mfmsr (void); Moves the contents of the MSR into bits 32 to 63 of the designated GPR. Execution of this instruction is privileged and restricted to supervisor mode only.
unsigned __mfspr(const int registerNumber); Returns the value of given special purpose register registerNumber. The registerNumber must be known at compile time.
void __mtmsr (unsigned long); Moves the contents of bits 32 to 63 of the designated GPR into the MSR. Execution of this instruction is privileged and restricted to supervisor mode only.
void __mtspr(const int registerNumber, unsigned long value); Sets the value of special purpose register registerNumber with unsigned long value. Both values must be known at compile time.