]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.arch/altivec-regs.exp
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / altivec-regs.exp
CommitLineData
1d506c26 1# Copyright (C) 2002-2024 Free Software Foundation, Inc.
57680a24
EZ
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
57680a24
EZ
6# (at your option) any later version.
7#
e22f8b7c 8# This program is distributed in the hope that it will be useful,
57680a24
EZ
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.
e22f8b7c 12#
57680a24 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
57680a24 15#
57680a24
EZ
16
17# Tests for Powerpc AltiVec register setting and fetching
18
57680a24
EZ
19#
20# Test the use of registers, especially AltiVec registers, for Powerpc.
21# This file uses altivec-regs.c for input.
22#
23
c2b7bed6 24require allow_altivec_tests
57680a24 25
20c2c024 26standard_testfile
57680a24 27
fc91c6c2 28set compile_flags {debug nowarnings}
d1779be4 29if [test_compiler_info gcc*] {
e7b1eae6 30 set compile_flags "$compile_flags additional_flags=-maltivec additional_flags=-mabi=altivec"
d1779be4
PG
31} elseif [test_compiler_info xlc*] {
32 set compile_flags "$compile_flags additional_flags=-qaltivec"
33} else {
34 warning "unknown compiler"
35 return -1
36}
37
38if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $compile_flags] != "" } {
5b362f04 39 untested "failed to compile"
b60f0898 40 return -1
57680a24
EZ
41}
42
43gdb_start
44gdb_reinitialize_dir $srcdir/$subdir
45gdb_load ${binfile}
46
47#
48# Run to `main' where we begin our tests.
49#
50
75b6f386 51if {![runto_main]} {
c8ee3f04 52 return 0
57680a24
EZ
53}
54
60204874
AVK
55gdb_breakpoint [gdb_get_line_number "start here"]
56gdb_continue_to_breakpoint "start here"
57
0d8f9b2c
NF
58gdb_test "set print frame-arguments all"
59
57680a24
EZ
60# set all the registers integer portions to 1
61for {set i 0} {$i < 32} {incr i 1} {
62 for {set j 0} {$j < 4} {incr j 1} {
63 gdb_test "set \$vr$i.v4_int32\[$j\] = 1" "" "set reg vr$i.v4si.f\[$j\]"
64 }
65}
66
67gdb_test "set \$vscr = 1" "" ""
68gdb_test "set \$vrsave = 1" "" ""
69
70# Now execute some target code, so that GDB's register cache is flushed.
71
72gdb_test "next" "" ""
73
805acca0 74set endianness [get_endianness]
57680a24
EZ
75
76# And then read the AltiVec registers back, to see that
77# a) the register write above worked, and
78# b) the register read (below) also works.
79
80if {$endianness == "big"} {
0b60b963 81set vector_register ".uint128 = 0x1000000010000000100000001, v4_float = .0x1, 0x1, 0x1, 0x1., v4_int32 = .0x1, 0x1, 0x1, 0x1., v8_int16 = .0x0, 0x1, 0x0, 0x1, 0x0, 0x1, 0x0, 0x1., v16_int8 = .0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1.."
57680a24 82} else {
0b60b963 83set vector_register ".uint128 = 0x1000000010000000100000001, v4_float = .0x1, 0x1, 0x1, 0x1., v4_int32 = .0x1, 0x1, 0x1, 0x1., v8_int16 = .0x1, 0x0, 0x1, 0x0, 0x1, 0x0, 0x1, 0x0., v16_int8 = .0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0.."
57680a24
EZ
84}
85
86for {set i 0} {$i < 32} {incr i 1} {
6f072a10
PFC
87 gdb_test "info reg vr$i" "vr$i.*$vector_register" "info reg vr$i"
88 gdb_test "info reg v$i" "v$i.*$vector_register" "info reg v$i"
57680a24
EZ
89}
90
adf8243b
RK
91gdb_test "info reg vrsave" "vrsave.*0x1\[ \t\]+1" "info reg vrsave"
92gdb_test "info reg vscr" "vscr.*0x1\[ \t\]+1" "info reg vscr"
57680a24
EZ
93
94# Now redo the same tests, but using the print command.
95# Note: in LE case, the char array is printed WITHOUT the last character.
96# Gdb treats the terminating null char in the array like the terminating
97# null char in a string and doesn't print it. This is not a failure, but
98# the way gdb works.
99
100if {$endianness == "big"} {
0b60b963 101 set decimal_vector ".uint128 = 79228162532711081671548469249, v4_float = .1.*e-45, 1.*e-45, 1.*e-45, 1.*e-45., v4_int32 = .1, 1, 1, 1., v8_int16 = .0, 1, 0, 1, 0, 1, 0, 1., v16_int8 = .0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1.."
57680a24 102} else {
0b60b963 103 set decimal_vector ".uint128 = 79228162532711081671548469249, v4_float = .1.*e-45, 1.*e-45, 1.*e-45, 1.*e-45., v4_int32 = .1, 1, 1, 1., v8_int16 = .1, 0, 1, 0, 1, 0, 1, 0., v16_int8 = .1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.."
57680a24
EZ
104}
105
106for {set i 0} {$i < 32} {incr i 1} {
6f072a10
PFC
107 gdb_test "print \$vr$i" ".* = $decimal_vector" "print vr$i"
108 gdb_test "print \$v$i" ".* = $decimal_vector" "print v$i"
57680a24
EZ
109}
110
111gdb_test "print \$vrsave" ".* = 1" "print vrsave"
112gdb_test "print \$vscr" ".* = 1" "print vscr"
113
114for {set i 0} {$i < 32} {incr i 1} {
a7b8d682 115 lappend pattern_list "vr$i\[ \t\]+$vector_register"
57680a24
EZ
116}
117
a7b8d682
PFC
118lappend pattern_list "vscr\[ \t\]+0x1"
119lappend pattern_list "vrsave\[ \t\]+0x1"
120
561d7a1d 121send_gdb "info vector\n"
a7b8d682 122gdb_expect_list "info vector" ".*$gdb_prompt $" $pattern_list
57680a24
EZ
123
124gdb_test "break vector_fun" \
5992fb85 125 "Breakpoint $decimal at.*altivec-regs.c, line \[0-9\]+\\." \
bb95117e 126 "set breakpoint at vector_fun"
57680a24
EZ
127
128# Actually it is nuch easier to see these results printed in hex.
129gdb_test "set output-radix 16" \
130 "Output radix now set to decimal 16, hex 10, octal 20." \
bb95117e 131 "set output radix to hex"
57680a24
EZ
132
133gdb_test "continue" \
5992fb85 134 "Breakpoint $decimal, vector_fun .a=.0xfefefefe, 0xfefefefe, 0xfefefefe, 0xfefefefe., b=.0x1010101, 0x1010101, 0x1010101, 0x1010101.*altivec-regs.c.*vec_splat_u8.2..;" \
57680a24
EZ
135 "continue to vector_fun"
136
137# Do a next over the assignment to vector 'a'.
138gdb_test "next" ".*b = \\(\\(vector unsigned int\\) vec_splat_u8\\(3\\)\\);" \
139 "next (1)"
140
141# Do a next over the assignment to vector 'b'.
142gdb_test "next" "c = vec_add \\(a, b\\);" \
143 "next (2)"
144
145# Now 'a' should be '0x02020202...' and 'b' should be '0x03030303...'
146gdb_test "print/x a" \
147 ".*= .0x2020202, 0x2020202, 0x2020202, 0x2020202." \
148 "print vector parameter a"
149
150gdb_test "print/x b" \
151 ".*= .0x3030303, 0x3030303, 0x3030303, 0x3030303." \
152 "print vector parameter b"
153
154# If we do an 'up' now, and print 'x' and 'y' we should see the values they
155# have in main, not the values they have in vector_fun.
156gdb_test "up" ".1.*main \\(\\) at.*altivec-regs.c.*z = vector_fun \\(x, y\\);" \
157 "up to main"
158
159gdb_test "print/x x" \
160 ".*= .0xfefefefe, 0xfefefefe, 0xfefefefe, 0xfefefefe." \
161 "print vector x"
162
163gdb_test "print/x y" \
164 ".*= .0x1010101, 0x1010101, 0x1010101, 0x1010101." \
165 "print vector y"
166
167# now go back to vector_func and do a finish, to see if we can print the return
168# value correctly.
169
170gdb_test "down" \
171 ".0 vector_fun \\(a=.0x2020202, 0x2020202, 0x2020202, 0x2020202., b=.0x3030303, 0x3030303, 0x3030303, 0x3030303.\\) at.*altivec-regs.c.*c = vec_add \\(a, b\\);" \
172 "down to vector_fun"
173
174gdb_test "finish" \
175 "Run till exit from .0 vector_fun \\(a=.0x2020202, 0x2020202, 0x2020202, 0x2020202., b=.0x3030303, 0x3030303, 0x3030303, 0x3030303.\\) at.*altivec-regs.c.*in main \\(\\) at.*altivec-regs.c.*z = vector_fun \\(x, y\\);.*Value returned is.*= .0x5050505, 0x5050505, 0x5050505, 0x5050505." \
176 "finish returned correct value"
177
178
179