]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
nvptx: Add effective-target 'nvptx_softstack', use for effective-target 'alloca'
authorThomas Schwinge <tschwinge@baylibre.com>
Mon, 16 Dec 2024 10:48:11 +0000 (11:48 +0100)
committerThomas Schwinge <tschwinge@baylibre.com>
Wed, 8 Jan 2025 22:16:35 +0000 (23:16 +0100)
..., 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'.

gcc/doc/sourcebuild.texi
gcc/testsuite/lib/target-supports.exp

index f32f50b9c030c75040718e60698e9a695c08cf4c..0e0a7c806ebcb3f5b0a86cdc952c78bfe476f194 100644 (file)
@@ -2433,6 +2433,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
index e6a876d9301a4911d07cb8c1ccb1976117251e19..d7d7217be0582c03f1fa16acb760b0aece3b29df 100644 (file)
@@ -1009,10 +1009,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
 }
@@ -14099,6 +14100,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 } {