[nvptx, testsuite] Fix gcc.target/nvptx/alias-*.c on sm_80

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.
This commit is contained in:
Tom de Vries 2022-04-01 11:09:53 +02:00
parent 15d683d4f0
commit 215c8c5826
5 changed files with 70 additions and 12 deletions

View 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;

View 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"

View 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. */

View 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"

View 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.