Hi Olivier,

On 10/10/18 22:40, Olivier Hainque wrote:
Hello,

The aarch64 "platform register" r18 is currently
unconditionally used as a scratch register by gcc.

Working on a VxWorks port for this arch (that we
plan to contribute soon), we discovered that VxWorks
has an internal use of this register so it needs
to be considered "fixed" for this port.

Hence the attached patch proposal, which we have been
using successfully for a while now. It just introduces
a FIXED_R18 config macro, defaulted to 0, which an OS
specific config file may redefine.

Is this ok to commit ?


CC'ing the aarch64 maintainers as they'll have to approve it.
I'm guessing you've tested this in the usual way (bootstrap and test)?

Thanks in advance,

With Kind Regards,

Olivier


2018-03-18  Olivier Hainque  <hain...@adacore.com>

        * config/aarch64/aarch64.h (FIXED_R18): New
        internal configuration macro, defaulted to 0.
        (FIXED_REGISTERS): Use it.
        (STATIC_CHAIN_REGNUM): Fallback to r11 instead
        of r18 if the latter is fixed.


diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index fa9af26..2e69a4d 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -284,11 +284,13 @@ extern unsigned aarch64_architecture_version;
/* Standard register usage. */ +#define FIXED_R18 0
+


Any reason not to use the TARGET_CONDITIONAL_REGISTER_USAGE interface to adjust 
the fixed_regs table instead?
I'm not objecting to your approach here, just interested if you considered and 
rejected it.

Thanks,
Kyrill



 /* 31 64-bit general purpose registers R0-R30:
    R30         LR (link register)
    R29         FP (frame pointer)
    R19-R28     Callee-saved registers
-   R18         The platform register; use as temporary register.
+   R18         The platform register; use as temporary register if !FIXED_R18.
    R17         IP1 The second intra-procedure-call temporary register
                (can be used by call veneers and PLT code); otherwise use
                as a temporary register
@@ -324,7 +326,7 @@ extern unsigned aarch64_architecture_version;
   {                                                    \
     0, 0, 0, 0,   0, 0, 0, 0,  /* R0 - R7 */           \
     0, 0, 0, 0,   0, 0, 0, 0,  /* R8 - R15 */          \
-    0, 0, 0, 0,   0, 0, 0, 0,  /* R16 - R23 */         \
+    0, 0, FIXED_R18, 0, 0, 0, 0, 0,    /* R16 - R23 */         \
     0, 0, 0, 0,   0, 1, 0, 1,  /* R24 - R30, SP */     \
     0, 0, 0, 0,   0, 0, 0, 0,   /* V0 - V7 */           \
     0, 0, 0, 0,   0, 0, 0, 0,   /* V8 - V15 */         \
@@ -419,7 +421,7 @@ extern unsigned aarch64_architecture_version;
    uses alloca.  */
 #define EXIT_IGNORE_STACK      (cfun->calls_alloca)
-#define STATIC_CHAIN_REGNUM R18_REGNUM
+#define STATIC_CHAIN_REGNUM            (!(FIXED_R18) ? R18_REGNUM : R11_REGNUM)
 #define HARD_FRAME_POINTER_REGNUM      R29_REGNUM
 #define FRAME_POINTER_REGNUM           SFP_REGNUM
 #define STACK_POINTER_REGNUM           SP_REGNUM


Reply via email to