https://gcc.gnu.org/g:1fbf61f0efd39eaa3095f4537dcc4f3582146f01

commit 1fbf61f0efd39eaa3095f4537dcc4f3582146f01
Author: Thomas Schwinge <tschwi...@baylibre.com>
Date:   Tue Dec 10 11:11:26 2024 +0100

    nvptx: Clarify that the PTX "native" stack pointer is handled implicitly at 
function level [PR65181]
    
            PR target/65181
            gcc/
            * config/nvptx/nvptx.h (STACK_SAVEAREA_MODE): '#define'.
            * config/nvptx/nvptx.md [!TARGET_SOFT_STACK]
            (save_stack_function): 'define_expand'.
            (restore_stack_function): Handle '!TARGET_SOFT_STACK'.

Diff:
---
 gcc/ChangeLog.omp         |  6 ++++++
 gcc/config/nvptx/nvptx.h  |  7 +++++++
 gcc/config/nvptx/nvptx.md | 13 +++++++++++++
 3 files changed, 26 insertions(+)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 95c0ca220ec8..d06ff6ba1e87 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,5 +1,11 @@
 2024-12-18  Thomas Schwinge  <tschwi...@baylibre.com>
 
+       PR target/65181
+       * config/nvptx/nvptx.h (STACK_SAVEAREA_MODE): '#define'.
+       * config/nvptx/nvptx.md [!TARGET_SOFT_STACK]
+       (save_stack_function): 'define_expand'.
+       (restore_stack_function): Handle '!TARGET_SOFT_STACK'.
+
        PR target/65181
        * config/nvptx/nvptx.md [!TARGET_SOFT_STACK] (save_stack_block):
        'define_expand'.
diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
index c8c402475a8e..42e86c17e3f4 100644
--- a/gcc/config/nvptx/nvptx.h
+++ b/gcc/config/nvptx/nvptx.h
@@ -89,6 +89,13 @@
 #define Pmode (TARGET_ABI64 ? DImode : SImode)
 #define STACK_SIZE_MODE Pmode
 
+/* We always have to maintain the '-msoft-stack' pointer, but the PTX "native"
+   stack pointer is handled implicitly at function level.  */
+#define STACK_SAVEAREA_MODE(LEVEL) \
+  (TARGET_SOFT_STACK ? Pmode \
+   : (LEVEL == SAVE_FUNCTION ? VOIDmode \
+      : Pmode))
+
 #include "nvptx-gen.h"
 
 /* There are no 'TARGET_PTX_3_1' and smaller conditionals: our baseline is
diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md
index 816d09f35102..1afa61903ca9 100644
--- a/gcc/config/nvptx/nvptx.md
+++ b/gcc/config/nvptx/nvptx.md
@@ -1736,11 +1736,24 @@
   DONE;
 })
 
+(define_expand "save_stack_function"
+  [(match_operand 0 "register_operand" "")
+   (match_operand 1 "register_operand" "")]
+  "!TARGET_SOFT_STACK"
+{
+  /* See 'STACK_SAVEAREA_MODE'.  */
+  gcc_checking_assert (operands[0] == 0);
+  DONE;
+})
+
 (define_expand "restore_stack_function"
   [(match_operand 0 "register_operand" "")
    (match_operand 1 "register_operand" "")]
   ""
 {
+  if (!TARGET_SOFT_STACK)
+    /* See 'STACK_SAVEAREA_MODE'.  */
+    gcc_checking_assert (operands[1] == 0);
   DONE;
 })

Reply via email to