Is it possible to force a compiler (gcc or clang in my case) to use a certain register, lets say R15 on x86_64 for a certain variable and also prohibit it from using R15 for any other purpose besides that variable.
gcc can do it.
The already cited gcc docs answers your question of how to force a variable into a certain register.
To stop the compiler from generating code using this register for other purposes, use the gcc switch -ffixed-reg (see gcc doc for details).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With