[PATCH 16/57][Arm][GAS] Add support for MVE instructions: vdup, vddup, vdwdup, vidup...
[binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-avx512.exp
blob9b1ee2525b1976ace61896ba8c2fc764fc18f309
1 # Copyright 2014-2019 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Please email any bugs, comments, and/or additions to this file to:
17 # bug-gdb@gnu.org
19 # This file is part of the gdb testsuite.
22 if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
23     verbose "Skipping x86 AVX512 tests."
24     return
27 standard_testfile
29 set comp_flags "-mavx512f -I${srcdir}/../nat"
31 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
32      [list debug nowarnings additional_flags=${comp_flags}]] } {
33     return -1
36 if ![runto_main] {
37     untested "could not run to main"
38     return -1
41 set supports_avx512 0
43 set test "probe AVX512 support"
44 gdb_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     }
54 if { !$supports_avx512 } {
55     unsupported "processor does not support AVX512"
56     return
59 gdb_test "break [gdb_get_line_number "first breakpoint here"]" \
60     "Breakpoint .* at .*i386-avx512.c.*" \
61     "set first breakpoint in main"
62 gdb_continue_to_breakpoint "continue to first breakpoint in main"
64 set nr_regs 8
66 for { 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"
72 for { set r 1 } { $r < $nr_regs } { incr r } {
73     gdb_test "set var \$k$r = 0x$r$r$r$r" "" "set %k$r"
76 gdb_test "break [gdb_get_line_number "second breakpoint here"]" \
77     "Breakpoint .* at .*i386-avx512.c.*" \
78     "set second breakpoint in main"
79 gdb_continue_to_breakpoint "continue to second breakpoint in main"
81 set nr_regs 7
83 for { 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\]"
90 gdb_test "break [gdb_get_line_number "third breakpoint here"]" \
91     "Breakpoint .* at .*i386-avx512.c.*" \
92     "set third breakpoint in main"
93 gdb_continue_to_breakpoint "continue to third breakpoint in main"
95 if [is_amd64_regs_target] {
96     set nr_regs 32
97 } else {
98     set nr_regs 8
101 for { 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"
122 for { 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\]"
133 gdb_test "break [gdb_get_line_number "fourth breakpoint here"]" \
134     "Breakpoint .* at .*i386-avx512.c.*" \
135     "set fourth breakpoint in main"
136 gdb_continue_to_breakpoint "continue to fourth breakpoint in main"
138 for { 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"
144 for { 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\]"
151 gdb_test "break [gdb_get_line_number "fifth breakpoint here"]" \
152     "Breakpoint .* at .*i386-avx512.c.*" \
153     "set fifth breakpoint in main"
154 gdb_continue_to_breakpoint "continue to fifth breakpoint in main"
156 for { 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"
162 for { 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\]"
167 gdb_test "break [gdb_get_line_number "sixth breakpoint here"]" \
168     "Breakpoint .* at .*i386-avx512.c.*" \
169     "set sixth breakpoint in main"
170 gdb_continue_to_breakpoint "continue to sixth breakpoint in main"
172 for { 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"
178 gdb_test "break [gdb_get_line_number "seventh breakpoint here"]" \
179     "Breakpoint .* at .*i386-avx512.c.*" \
180     "set seventh breakpoint in main"
181 gdb_continue_to_breakpoint "continue to seventh breakpoint in main"
182 gdb_test "print \$zmm0.v16_int32" "= {-1, -1, -1, -1, 0 <repeats 12 times>}"
184 if { $nr_regs >= 16 } {
185     gdb_test "print \$zmm16.v16_int32" "= {-1 <repeats 16 times>}"