Why is arm64 built with -ffixed-r9 ?

Looking at one of the .o.cmd files, I noticed that we build arm64 with both -ffixed-r9 and -ffixed-x18. The latter is obviously what we use for gd, but the former doesn't seem to serve any purpose on arm64, and just seems to be an accident of the makefile fragment organization.
When I just remove -ffixed-r9 from arch/arm/config.mk, it builds and boots just fine (a real patch would of course do some ifndef CONFIG_ARM64 thing). The code does change, generally of the form "use x9 instead of x10, x10 instead of x11" etc., i.e. the expected register allocation changes. But the total space saving from having that extra scratch reg is almost non-existing; a mere 44 bytes for u-boot proper; apparently aarch64 has plenty of scratch registers even if one is reserved-and-never-used.
Still, it's somewhat confusing, so if for some reason this is really needed in some cases (calling into some 32 bit firmware???), I'd like a comment somewhere.
Rasmus

On Mon, Aug 08, 2022 at 04:34:00PM +0200, Rasmus Villemoes wrote:
Looking at one of the .o.cmd files, I noticed that we build arm64 with both -ffixed-r9 and -ffixed-x18. The latter is obviously what we use for gd, but the former doesn't seem to serve any purpose on arm64, and just seems to be an accident of the makefile fragment organization.
When I just remove -ffixed-r9 from arch/arm/config.mk, it builds and boots just fine (a real patch would of course do some ifndef CONFIG_ARM64 thing). The code does change, generally of the form "use x9 instead of x10, x10 instead of x11" etc., i.e. the expected register allocation changes. But the total space saving from having that extra scratch reg is almost non-existing; a mere 44 bytes for u-boot proper; apparently aarch64 has plenty of scratch registers even if one is reserved-and-never-used.
Still, it's somewhat confusing, so if for some reason this is really needed in some cases (calling into some 32 bit firmware???), I'd like a comment somewhere.
I strongly suspect this is just a remnant of how the Makefile logic is, and that since nothing failed with -ffixed-r9 it just kept being used.
participants (2)
-
Rasmus Villemoes
-
Tom Rini