Apple x18 on ARM

Uwe Falck uwe at falcknet.de
Mon Mar 7 11:35:20 CET 2022


Hello,

I don’t like your comment on Apple reserving x18 for platform purposes on the GMP home page.

> 	• While we added support for Apple's new Arm based computers, our support has a problem. The problem is that Apple reserves CPU register x18, but GMP's mpn/arm64 assembly code uses that register. While GMP runs fine in our tests, we expect things to go awry in some execution situation. (Apple has not been kind enough to specify how they use x18. Therefore, we don't know what the consequences of using x18 might be.)
> 

The ARM ABI documentation https://developer.arm.com/documentation/ihi0055/latest says very clearly for several years

> The role of register r18 is platform specific. If a platform ABI has need of a dedicated general purpose register to carry inter-procedural state (for example, the thread context) then it should use this register for that purpose. If the platform ABI has no such requirements, then it should use r18 as an additional temporary register. The platform ABI specification must document the usage for this register.
> 
> Note
> 
> Software developers creating platform-independent code are advised to avoid using r18 if at all possible. Most compilers provide a mechanism to prevent specific registers from being used for general allocation; portable hand-coded assembler should avoid it entirely. It should not be assumed that treating the register as callee-saved will be sufficient to satisfy the requirements of the platform. Virtualization code must, of course, treat the register as they would any other resource provided to the virtual machine.
> 

Therefore I would prefer not to blame Apple for using x18 on ARM as you like as GMP developers.

Kind regards
Uwe


More information about the gmp-discuss mailing list