GCC provides a couple of special builtin functions to aid in utilizing special PRU instructions.
The built-in functions supported are:
__delay_cycles (long long cycles)
This inserts an instruction sequence that takes exactly cycles cycles (between 0 and 0xffffffff) to complete. The inserted sequence may use jumps, loops, or no-ops, and does not interfere with any other instructions. Note that cycles must be a compile-time constant integer - that is, you must pass a number, not a variable that may be optimized to a constant later. The number of cycles delayed by this builtin is exact.
__halt (void)
This inserts a HALT instruction to stop processor execution.
unsigned int __lmbd (unsigned int wordval, unsigned int bitval)
This inserts LMBD instruction to calculate the left-most bit with value bitval in value wordval. Only the least significant bit of bitval is taken into account.
© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-11.1.0/gcc/PRU-Built_002din-Functions.html