diff mbox series

move and adjust PROBE_STACK_*_REG on aarch64

Message ID 27F1EC32-16A0-4F5C-BF49-6C48DB72881D@adacore.com
State New
Headers show
Series move and adjust PROBE_STACK_*_REG on aarch64 | expand

Commit Message

Olivier Hainque Dec. 19, 2019, 5:38 p.m. UTC
Hello,

The attached patch is a standalone part of a slightly more
general change last discussed here:

  https://gcc.gnu.org/ml/gcc-patches/2019-11/msg02626.html

Which I re-tested successfully on aarch64-linux (bootstrap
and regression test with --enable-languages=all + local tests
with Ada stack-checking on a gcc-9 based toolchain in-house).

The change moves the definitions of PROBE_STACK_FIRST_REG
and PROBE_STACK_SECOND_REG to a more appropriate place for such
items (here, in aarch64.md as suggested by Richard), and adjust
their value from r9/r10 to r10/r11 to free r9 for a possibly
more general purpose (e.g. as a static chain at least on targets
which have a private use of r18, such as Windows or Vxworks).

Is this ok to commit ?

Thanks in advance!

With Kind Regards,

Olivier

--

> 2019-11-07  Olivier Hainque  <hainque@adacore.com>
> 
> 	* config/aarch64/aarch64.md: Define PROBE_STACK_FIRST_REGNUM
> 	and PROBE_STACK_SECOND_REGNUM constants, designating r10/r11.
> 	Replacements for the PROBE_STACK_FIRST/SECOND_REG constants in
> 	aarch64.c.
> 	* config/aarch64/aarch64.c (PROBE_STACK_FIRST_REG): Remove.
> 	(PROBE_STACK_SECOND_REG): Remove.
> 	(aarch64_emit_probe_stack_range): Adjust to the _REG -> _REGNUM
> 	suffix update for PROBE_STACK register numbers.

Comments

Olivier Hainque Jan. 9, 2020, 10:47 a.m. UTC | #1
Hello,

Gentle ping for 

  https://gcc.gnu.org/ml/gcc-patches/2019-12/msg01398.html

I realize and certainly understand that this is
of lower importance than other matters currently being discussed
on the lists.

It's just that the end of stage 3 is imminent and I thought
we'd better at least agree on a way forward before it closes.

This particular change is an extraction of an hopefully
non controversial part of a more general change discussed
earlier. No ABI concern here.

Thanks in advance!

Cheers,

Olivier

> On 19 Dec 2019, at 18:38, Olivier Hainque <hainque@adacore.com> wrote:
> 
> Hello,
> 
> The attached patch is a standalone part of a slightly more
> general change last discussed here:
> 
>  https://gcc.gnu.org/ml/gcc-patches/2019-11/msg02626.html
> 
> Which I re-tested successfully on aarch64-linux (bootstrap
> and regression test with --enable-languages=all + local tests
> with Ada stack-checking on a gcc-9 based toolchain in-house).
> 
> The change moves the definitions of PROBE_STACK_FIRST_REG
> and PROBE_STACK_SECOND_REG to a more appropriate place for such
> items (here, in aarch64.md as suggested by Richard), and adjust
> their value from r9/r10 to r10/r11 to free r9 for a possibly
> more general purpose (e.g. as a static chain at least on targets
> which have a private use of r18, such as Windows or Vxworks).
> 
> Is this ok to commit ?
> 
> Thanks in advance!
> 
> With Kind Regards,
> 
> Olivier
> 
> --
> 
>> 2019-11-07  Olivier Hainque  <hainque@adacore.com>
>> 
>> 	* config/aarch64/aarch64.md: Define PROBE_STACK_FIRST_REGNUM
>> 	and PROBE_STACK_SECOND_REGNUM constants, designating r10/r11.
>> 	Replacements for the PROBE_STACK_FIRST/SECOND_REG constants in
>> 	aarch64.c.
>> 	* config/aarch64/aarch64.c (PROBE_STACK_FIRST_REG): Remove.
>> 	(PROBE_STACK_SECOND_REG): Remove.
>> 	(aarch64_emit_probe_stack_range): Adjust to the _REG -> _REGNUM
>> 	suffix update for PROBE_STACK register numbers.
> 
> <0001-Move-and-adjust-PROBE_STACK-reg-definitions-for-aarc.patch.txt>
diff mbox series

Patch

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 1dfff33..b5a2815 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -5435,10 +5435,6 @@  aarch64_libgcc_cmp_return_mode (void)
 #error Cannot use simple address calculation for stack probing
 #endif
 
-/* The pair of scratch registers used for stack probing.  */
-#define PROBE_STACK_FIRST_REG  R9_REGNUM
-#define PROBE_STACK_SECOND_REG R10_REGNUM
-
 /* Emit code to probe a range of stack addresses from FIRST to FIRST+POLY_SIZE,
    inclusive.  These are offsets from the current stack pointer.  */
 
@@ -5452,7 +5448,7 @@  aarch64_emit_probe_stack_range (HOST_WIDE_INT first, poly_int64 poly_size)
       return;
     }
 
-  rtx reg1 = gen_rtx_REG (Pmode, PROBE_STACK_FIRST_REG);
+  rtx reg1 = gen_rtx_REG (Pmode, PROBE_STACK_FIRST_REGNUM);
 
   /* See the same assertion on PROBE_INTERVAL above.  */
   gcc_assert ((first % ARITH_FACTOR) == 0);
@@ -5510,7 +5506,7 @@  aarch64_emit_probe_stack_range (HOST_WIDE_INT first, poly_int64 poly_size)
      equality test for the loop condition.  */
   else
     {
-      rtx reg2 = gen_rtx_REG (Pmode, PROBE_STACK_SECOND_REG);
+      rtx reg2 = gen_rtx_REG (Pmode, PROBE_STACK_SECOND_REGNUM);
 
       /* Step 1: round SIZE to the previous multiple of the interval.  */
 
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index f19e227..2775d75e 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -111,6 +111,10 @@ 
     ;; "FFR token": a fake register used for representing the scheduling
     ;; restrictions on FFR-related operations.
     (FFRT_REGNUM	85)
+    ;; The pair of scratch registers used for stack probing with -fstack-check.
+    ;; Leave R9 alone as a possible choice for more general purposes.
+    (PROBE_STACK_FIRST_REGNUM  10)
+    (PROBE_STACK_SECOND_REGNUM 11)
     ;; Scratch register used by stack clash protection to calculate
     ;; SVE CFA offsets during probing.
     (STACK_CLASH_SVE_CFA_REGNUM 11)