https://gcc.gnu.org/g:1597362730241fff464e663f0225b2deef8ffa8f

commit 1597362730241fff464e663f0225b2deef8ffa8f
Author: Thomas Schwinge <tschwi...@baylibre.com>
Date:   Mon Dec 16 11:48:11 2024 +0100

    nvptx: Add effective-target 'nvptx_softstack', use for effective-target 
'alloca'
    
    ..., and thereby making the check for effective-target 'alloca' more 
explicit.
    As of commit 5012919d0bd344ac1888e8e531072f0ccbe24d2c (Subversion r242503)
    "nvptx backend prerequisites for OpenMP offloading", the check for
    effective-target 'alloca' did "use a compile test"; let's make this more
    explicit: supported for '-msoft-stack', not supported otherwise.
    
            gcc/testsuite/
            * lib/target-supports.exp
            (check_effective_target_nvptx_softstack): New.
            (check_effective_target_alloca) [nvptx]: Use it.
            gcc/
            * doc/sourcebuild.texi (Effective-Target Keywords): Document
            'nvptx_softstack'.

Diff:
---
 gcc/ChangeLog.omp                     |  3 +++
 gcc/doc/sourcebuild.texi              |  3 +++
 gcc/testsuite/ChangeLog.omp           |  4 ++++
 gcc/testsuite/lib/target-supports.exp | 19 +++++++++++++++----
 4 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index d06ff6ba1e87..68aada429c25 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,5 +1,8 @@
 2024-12-18  Thomas Schwinge  <tschwi...@baylibre.com>
 
+       * doc/sourcebuild.texi (Effective-Target Keywords): Document
+       'nvptx_softstack'.
+
        PR target/65181
        * config/nvptx/nvptx.h (STACK_SAVEAREA_MODE): '#define'.
        * config/nvptx/nvptx.md [!TARGET_SOFT_STACK]
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index df2b5bf1ee92..1385f80e9b07 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2418,6 +2418,9 @@ nvptx code by default compiles for at least PTX ISA 
version 6.0.
 @item nvptx_runtime_alias_ptx
 The nvptx runtime environment supports the PTX ISA directive
 @code{.alias}.
+
+@item nvptx_softstack
+nvptx @option{-msoft-stack} is enabled.
 @end table
 
 @subsubsection PowerPC-specific attributes
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 0f933749b622..3035aeb85779 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,5 +1,9 @@
 2024-12-18  Thomas Schwinge  <tschwi...@baylibre.com>
 
+       * lib/target-supports.exp
+       (check_effective_target_nvptx_softstack): New.
+       (check_effective_target_alloca) [nvptx]: Use it.
+
        PR target/65181
        * gcc.target/nvptx/__builtin_stack_save___builtin_stack_restore-1.c:
        Adjust.
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index f52aad73131e..7734d2949ab2 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -994,10 +994,11 @@ proc check_effective_target_alloca {} {
       return 0
     }
     if { [istarget nvptx-*-*] } {
-       return [check_no_compiler_messages alloca assembly {
-           void f (void*);
-           void g (int n) { f (__builtin_alloca (n)); }
-       }]
+       if { ![check_effective_target_nvptx_softstack] } {
+           return 0
+       } else {
+           return 1
+       }
     }
     return 1
 }
@@ -13593,6 +13594,16 @@ proc 
check_effective_target_nvptx_default_ptx_isa_version_at_least_6_0 { } {
     return [check_nvptx_default_ptx_isa_version_at_least 6 0]
 }
 
+# Return 1 if nvptx '-msoft-stack' is enabled.
+
+proc check_effective_target_nvptx_softstack { } {
+    return [check_no_compiler_messages nvptx_softstack assembly {
+       #if !defined(__nvptx_softstack__)
+       #error !__nvptx_softstack__
+       #endif
+    }]
+}
+
 # Return 1 if nvptx code with PTX ISA version major.minor or higher can be run.
 
 proc check_nvptx_runtime_ptx_isa_version_at_least { major minor } {

Reply via email to