xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.arch/i386-avx512.exp (revision 9fb66d812c00ebfb445c0b47dea128f32aa6fe96)
1# Copyright 2014-2019 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16# Please email any bugs, comments, and/or additions to this file to:
17# bug-gdb@gnu.org
18
19# This file is part of the gdb testsuite.
20
21
22if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
23    verbose "Skipping x86 AVX512 tests."
24    return
25}
26
27standard_testfile
28
29set comp_flags "-mavx512f -I${srcdir}/../nat"
30
31if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
32     [list debug nowarnings additional_flags=${comp_flags}]] } {
33    return -1
34}
35
36if ![runto_main] {
37    untested "could not run to main"
38    return -1
39}
40
41set supports_avx512 0
42
43set test "probe AVX512 support"
44gdb_test_multiple "print have_avx512()" $test {
45    -re ".. = 1\r\n$gdb_prompt $" {
46        pass $test
47        set supports_avx512 1
48    }
49    -re ".. = 0\r\n$gdb_prompt $" {
50        pass $test
51    }
52}
53
54if { !$supports_avx512 } {
55    unsupported "processor does not support AVX512"
56    return
57}
58
59gdb_test "break [gdb_get_line_number "first breakpoint here"]" \
60    "Breakpoint .* at .*i386-avx512.c.*" \
61    "set first breakpoint in main"
62gdb_continue_to_breakpoint "continue to first breakpoint in main"
63
64set nr_regs 8
65
66for { set r 1 } { $r < $nr_regs } { incr r } {
67    gdb_test "print/x \$k$r" \
68        ".. = 0x[format %x $r]2[format %x $r]1" \
69        "check contents of %k$r"
70}
71
72for { set r 1 } { $r < $nr_regs } { incr r } {
73    gdb_test "set var \$k$r = 0x$r$r$r$r" "" "set %k$r"
74}
75
76gdb_test "break [gdb_get_line_number "second breakpoint here"]" \
77    "Breakpoint .* at .*i386-avx512.c.*" \
78    "set second breakpoint in main"
79gdb_continue_to_breakpoint "continue to second breakpoint in main"
80
81set nr_regs 7
82
83for { set r 0 } { $r < $nr_regs } { incr r } {
84    set val [expr $r + 1]
85    gdb_test "print/x k_data\[$r\]" \
86        ".. = 0x$val$val$val$val" \
87        "check contents of k_data\[$r\]"
88}
89
90gdb_test "break [gdb_get_line_number "third breakpoint here"]" \
91    "Breakpoint .* at .*i386-avx512.c.*" \
92    "set third breakpoint in main"
93gdb_continue_to_breakpoint "continue to third breakpoint in main"
94
95if [is_amd64_regs_target] {
96    set nr_regs 32
97} else {
98    set nr_regs 8
99}
100
101for { set r 0 } { $r < $nr_regs } { incr r } {
102    gdb_test "print \$zmm$r.v8_double" \
103        ".. = \\{$r, $r.125, $r.25, $r.375, $r.5, $r.625, $r.75, $r.875\\}.*" \
104        "check double contents of %zmm$r"
105    gdb_test "print \$zmm$r.v32_int16" \
106        ".. = \\{(-?\[0-9\]+, ){31}-?\[0-9\]+\\}.*" \
107        "check int16 contents of %zmm$r"
108    gdb_test "print \$ymm$r.v4_double" \
109        ".. = \\{$r, $r.125, $r.25, $r.375\\}.*" \
110        "check float contents of %ymm$r"
111    gdb_test "print \$ymm$r.v16_int16" \
112        ".. = \\{(-?\[0-9\]+, ){15}-?\[0-9\]+\\}.*" \
113        "check int16 contents of %ymm$r"
114    gdb_test "print \$xmm$r.v2_double" \
115        ".. = \\{$r, $r.125\\}.*" \
116        "check float contents of %xmm$r"
117    gdb_test "print \$xmm$r.v8_int16" \
118        ".. = \\{(-?\[0-9\]+, ){7}-?\[0-9\]+\\}.*" \
119        "check int16 contents of %xmm$r"
120}
121
122for { set r 0 } { $r < $nr_regs } { incr r } {
123    gdb_test "set var \$zmm$r.v8_double\[0\] = $r + 10" "" "set %zmm$r.v8_double\[0\]"
124    gdb_test "set var \$zmm$r.v8_double\[1\] = $r + 10.125" "" "set %zmm$r.v8_double\[1\]"
125    gdb_test "set var \$zmm$r.v8_double\[2\] = $r + 10.25" "" "set %zmm$r.v8_double\[2\]"
126    gdb_test "set var \$zmm$r.v8_double\[3\] = $r + 10.375" "" "set %zmm$r.v8_double\[3\]"
127    gdb_test "set var \$zmm$r.v8_double\[4\] = $r + 10.5" "" "set %zmm$r.v8_double\[4\]"
128    gdb_test "set var \$zmm$r.v8_double\[5\] = $r + 10.625" "" "set %zmm$r.v8_double\[5\]"
129    gdb_test "set var \$zmm$r.v8_double\[6\] = $r + 10.75" "" "set %zmm$r.v8_double\[6\]"
130    gdb_test "set var \$zmm$r.v8_double\[7\] = $r + 10.875" "" "set %zmm$r.v8_double\[7\]"
131}
132
133gdb_test "break [gdb_get_line_number "fourth breakpoint here"]" \
134    "Breakpoint .* at .*i386-avx512.c.*" \
135    "set fourth breakpoint in main"
136gdb_continue_to_breakpoint "continue to fourth breakpoint in main"
137
138for { set r 0 } { $r < $nr_regs } { incr r } {
139    gdb_test "print zmm_data\[$r\]" \
140        ".. = \\{f = \\{[expr $r + 10], [expr $r.125 + 10], [expr $r.25 + 10], [expr $r.375 + 10], [expr $r.5 + 10], [expr $r.625 + 10], [expr $r.75 + 10], [expr $r.875 + 10]\\}\\}.*" \
141        "check contents of zmm_data\[$r\] after writing ZMM regs"
142}
143
144for { set r 0 } { $r < $nr_regs } { incr r } {
145    gdb_test "set var \$ymm$r.v4_double\[0\] = $r + 20" "" "set %ymm$r.v4_double\[0\]"
146    gdb_test "set var \$ymm$r.v4_double\[1\] = $r + 20.125" "" "set %ymm$r.v4_double\[1\]"
147    gdb_test "set var \$ymm$r.v4_double\[2\] = $r + 20.25" "" "set %ymm$r.v4_double\[2\]"
148    gdb_test "set var \$ymm$r.v4_double\[3\] = $r + 20.375" "" "set %ymm$r.v4_double\[3\]"
149}
150
151gdb_test "break [gdb_get_line_number "fifth breakpoint here"]" \
152    "Breakpoint .* at .*i386-avx512.c.*" \
153    "set fifth breakpoint in main"
154gdb_continue_to_breakpoint "continue to fifth breakpoint in main"
155
156for { set r 0 } { $r < $nr_regs } { incr r } {
157    gdb_test "print zmm_data\[$r\]" \
158        ".. = \\{f = \\{[expr $r + 20], [expr $r.125 + 20], [expr $r.25 + 20], [expr $r.375 + 20], [expr $r.5 + 10], [expr $r.625 + 10], [expr $r.75 + 10], [expr $r.875 + 10]\\}\\}.*" \
159        "check contents of zmm_data\[$r\] after writing YMM regs"
160}
161
162for { set r 0 } { $r < $nr_regs } { incr r } {
163    gdb_test "set var \$xmm$r.v2_double\[0\] = $r + 30" "" "set %xmm$r.v2_double\[0\]"
164    gdb_test "set var \$xmm$r.v2_double\[1\] = $r + 30.125" "" "set %xmm$r.v2_double\[1\]"
165}
166
167gdb_test "break [gdb_get_line_number "sixth breakpoint here"]" \
168    "Breakpoint .* at .*i386-avx512.c.*" \
169    "set sixth breakpoint in main"
170gdb_continue_to_breakpoint "continue to sixth breakpoint in main"
171
172for { set r 0 } { $r < $nr_regs } { incr r } {
173    gdb_test "print zmm_data\[$r\]" \
174        ".. = \\{f = \\{[expr $r + 30], [expr $r.125 + 30], [expr $r.25 + 20], [expr $r.375 + 20], [expr $r.5 + 10], [expr $r.625 + 10], [expr $r.75 + 10], [expr $r.875 + 10]\\}\\}.*" \
175        "check contents of zmm_data\[$r\] after writing XMM regs"
176}
177
178gdb_test "break [gdb_get_line_number "seventh breakpoint here"]" \
179    "Breakpoint .* at .*i386-avx512.c.*" \
180    "set seventh breakpoint in main"
181gdb_continue_to_breakpoint "continue to seventh breakpoint in main"
182gdb_test "print \$zmm0.v16_int32" "= {-1, -1, -1, -1, 0 <repeats 12 times>}"
183
184if { $nr_regs >= 16 } {
185    gdb_test "print \$zmm16.v16_int32" "= {-1 <repeats 16 times>}"
186}
187