]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[nvptx, testsuite] Fix gcc.target/nvptx/alias-*.c on sm_80
authorTom de Vries <tdevries@suse.de>
Fri, 1 Apr 2022 09:09:53 +0000 (11:09 +0200)
committerTom de Vries <tdevries@suse.de>
Fri, 1 Apr 2022 09:33:57 +0000 (11:33 +0200)
When running test-cases gcc.target/nvptx/alias-*.c on target board
nvptx-none-run/-misa=sm_80 we run into fails because the test-cases add
-mptx=6.3, which doesn't support sm_80.

Fix this by only adding -mptx=6.3 if necessary, and simplify the test-cases by
using ptx_alias feature abstractions:
...
/* { dg-do run { target runtime_ptx_alias } } */
/* { dg-add-options ptx_alias } */
...

Tested on nvptx.

gcc/testsuite/ChangeLog:

2022-04-01  Tom de Vries  <tdevries@suse.de>

* gcc.target/nvptx/nvptx.exp
(check_effective_target_runtime_ptx_isa_version_6_3): Rename and
generalize to ...
(check_effective_target_runtime_ptx_isa_version_at_least): .. this.
(check_effective_target_default_ptx_isa_version_at_least)
(check_effective_target_runtime_ptx_alias, add_options_for_ptx_alias):
New proc.
* gcc.target/nvptx/alias-1.c: Use "target runtime_ptx_alias" and
"dg-add-options ptx_alias".
* gcc.target/nvptx/alias-2.c: Same.
* gcc.target/nvptx/alias-3.c: Same.
* gcc.target/nvptx/alias-4.c: Same.

gcc/testsuite/gcc.target/nvptx/alias-1.c
gcc/testsuite/gcc.target/nvptx/alias-2.c
gcc/testsuite/gcc.target/nvptx/alias-3.c
gcc/testsuite/gcc.target/nvptx/alias-4.c
gcc/testsuite/gcc.target/nvptx/nvptx.exp

index f68716e77dd6dc346f012b819cf24bbc23db984e..d251eee6e423e22affeb36455474e92cb595f9dc 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do link } */
-/* { dg-do run { target runtime_ptx_isa_version_6_3 } } */
-/* { dg-options "-save-temps -malias -mptx=6.3" } */
+/* { dg-do run { target runtime_ptx_alias } } */
+/* { dg-options "-save-temps" } */
+/* { dg-add-options ptx_alias } */
 
 int v;
 
index e2dc9b1f5aca472a6ba0a2192a82a1a5c93aa203..96cb7e2c1ef9d7715d1b186e868489971bf41544 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do link } */
-/* { dg-do run { target runtime_ptx_isa_version_6_3 } } */
-/* { dg-options "-save-temps -malias -mptx=6.3 -O2" } */
+/* { dg-do run { target runtime_ptx_alias } } */
+/* { dg-options "-save-temps -O2" } */
+/* { dg-add-options ptx_alias } */
 
 #include "alias-1.c"
 
index 60486e508269665e63848d0ccb47fb32ae75088a..39649e30b91d1c114fd8ee87b0b3f0e048ab7926 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do link } */
-/* { dg-do run { target runtime_ptx_isa_version_6_3 } } */
-/* { dg-options "-save-temps -malias -mptx=6.3" } */
+/* { dg-do run { target runtime_ptx_alias } } */
+/* { dg-options "-save-temps" } */
+/* { dg-add-options ptx_alias } */
 
 /* Copy of alias-1.c, with static __f and f.  */
 
index 956150a6b3f74cc7df69b365415710d2fa518a2c..28163c0faa0ccde43476a29b7328af4a591c5428 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do link } */
-/* { dg-do run { target runtime_ptx_isa_version_6_3 } } */
-/* { dg-options "-save-temps -malias -mptx=6.3 -O2" } */
+/* { dg-do run { target runtime_ptx_alias } } */
+/* { dg-options "-save-temps -O2" } */
+/* { dg-add-options ptx_alias } */
 
 #include "alias-3.c"
 
index e69b6d35feda7a42818e2300daee8a7ce8e63873..e9622ae7aaa8d5a550fb20981ef2b763a92af735 100644 (file)
@@ -25,11 +25,65 @@ if ![istarget nvptx*-*-*] then {
 # Load support procs.
 load_lib gcc-dg.exp
 
-# Return 1 if code with -mptx=6.3 can be run.
-proc check_effective_target_runtime_ptx_isa_version_6_3 { args } {
-    return [check_runtime run_ptx_isa_6_3 {
+# Return 1 if code by default compiles for at least PTX ISA version
+# major.minor.
+proc check_effective_target_default_ptx_isa_version_at_least { major minor } {
+    set name default_ptx_isa_version_at_least_${major}_${minor}
+
+    set supported_p \
+       [concat \
+            "((__PTX_ISA_VERSION_MAJOR__ == $major" \
+            "  && __PTX_ISA_VERSION_MINOR__ >= $minor)" \
+            " || (__PTX_ISA_VERSION_MAJOR__ > $major))"]
+
+    set src \
+       [list \
+            "#if $supported_p" \
+            "#else" \
+            "#error unsupported" \
+            "#endif"]
+    set src [join $src "\n"]
+    
+    set res [check_no_compiler_messages $name assembly $src ""]
+
+    return $res
+}
+
+# Return 1 if code with PTX ISA version major.minor or higher can be run.
+proc check_effective_target_runtime_ptx_isa_version_at_least { major minor } {
+    set name runtime_ptx_isa_version_${major}_${minor}
+
+    set default \
+       [check_effective_target_default_ptx_isa_version_at_least \
+            ${major} ${minor}]
+
+    if { $default } {
+       set flag ""
+    } else {
+       set flag "-mptx=$major.$minor"
+    }
+
+    set res [check_runtime $name {
        int main (void) { return 0; }
-    } "-mptx=6.3"]
+    } $flag]
+
+    return $res
+}
+
+# Return 1 if runtime environment support the PTX ISA directive .alias.
+proc check_effective_target_runtime_ptx_alias { } {
+    return [check_effective_target_runtime_ptx_isa_version_at_least 6 3]
+}
+
+# Add options to enable using PTX ISA directive .alias.
+proc add_options_for_ptx_alias { flags } {
+    append flags " -malias"
+
+    if { ![check_effective_target_default_ptx_isa_version_at_least 6 3] } {
+       append flags " -mptx=6.3"
+    }
+
+    return $flags
 }
 
 # If a testcase doesn't have special options, use these.