1 |
227 |
jeremybenn |
# Copyright (C) 2008, 2009, 2010 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 .
|
15 |
|
|
#
|
16 |
|
|
|
17 |
|
|
# Tests for Powerpc AltiVec register setting and fetching
|
18 |
|
|
|
19 |
|
|
if $tracelevel then {
|
20 |
|
|
strace $tracelevel
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
#
|
24 |
|
|
# Test the use of VSX registers, for Powerpc.
|
25 |
|
|
#
|
26 |
|
|
|
27 |
|
|
set prms_id 0
|
28 |
|
|
set bug_id 0
|
29 |
|
|
|
30 |
|
|
if {![istarget "powerpc*"] || [skip_vsx_tests]} then {
|
31 |
|
|
verbose "Skipping vsx register tests."
|
32 |
|
|
return
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
set testfile "vsx-regs"
|
36 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
37 |
|
|
set srcfile ${testfile}.c
|
38 |
|
|
|
39 |
|
|
set compile_flags {debug nowarnings quiet}
|
40 |
|
|
if [get_compiler_info $binfile] {
|
41 |
|
|
warning "get_compiler failed"
|
42 |
|
|
return -1
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
if [test_compiler_info gcc*] {
|
46 |
|
|
set compile_flags "$compile_flags additional_flags=-maltivec additional_flags=-mabi=altivec"
|
47 |
|
|
} elseif [test_compiler_info xlc*] {
|
48 |
|
|
set compile_flags "$compile_flags additional_flags=-qaltivec"
|
49 |
|
|
} else {
|
50 |
|
|
warning "unknown compiler"
|
51 |
|
|
return -1
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $compile_flags] != "" } {
|
55 |
|
|
untested vsx-regs.exp
|
56 |
|
|
return -1
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
gdb_start
|
60 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
61 |
|
|
gdb_load ${binfile}
|
62 |
|
|
|
63 |
|
|
# Run to `main' where we begin our tests.
|
64 |
|
|
|
65 |
|
|
if ![runto_main] then {
|
66 |
|
|
gdb_suppress_tests
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
# Data sets used throughout the test
|
70 |
|
|
|
71 |
|
|
set vector_register1 ".uint128 = 0x3ff4cccccccccccc0000000000000000, v4_float = .0x1, 0xf99999a0, 0x0, 0x0., v4_int32 = .0x3ff4cccc, 0xcccccccc, 0x0, 0x0., v8_int16 = .0x3ff4, 0xcccc, 0xcccc, 0xcccc, 0x0, 0x0, 0x0, 0x0., v16_int8 = .0x3f, 0xf4, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0.."
|
72 |
|
|
|
73 |
|
|
set vector_register2 "uint128 = 0xdeadbeefdeadbeefdeadbeefdeadbeef, v4_float = .0x0, 0x0, 0x0, 0x0., v4_int32 = .0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef., v8_int16 = .0xdead, 0xbeef, 0xdead, 0xbeef, 0xdead, 0xbeef, 0xdead, 0xbeef., v16_int8 = .0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef.."
|
74 |
|
|
|
75 |
|
|
set vector_register3 ".uint128 = 0x00000001000000010000000100000001, v4_float = .0x0, 0x0, 0x0, 0x0., 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.."
|
76 |
|
|
|
77 |
|
|
set float_register ".raw 0xdeadbeefdeadbeef."
|
78 |
|
|
|
79 |
|
|
# First run the F0~F31/VS0~VS31 tests
|
80 |
|
|
|
81 |
|
|
# 1: Set F0~F31 registers and check if it reflects on VS0~VS31.
|
82 |
|
|
for {set i 0} {$i < 32} {incr i 1} {
|
83 |
|
|
send_gdb "set \$f$i = 1\.3"
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
for {set i 0} {$i < 32} {incr i 1} {
|
87 |
|
|
gdb_test "info reg vs$i" "vs$i.*$vector_register1" "info reg vs$i (doubleword 0)"
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
# 2: Set VS0~VS31 registers and check if it reflects on F0~F31.
|
91 |
|
|
for {set i 0} {$i < 32} {incr i 1} {
|
92 |
|
|
for {set j 0} {$j < 4} {incr j 1} {
|
93 |
|
|
send_gdb "set \$vs$i.v4_int32\[$j\] = 0xdeadbeef"
|
94 |
|
|
}
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
for {set i 0} {$i < 32} {incr i 1} {
|
98 |
|
|
gdb_test "info reg f$i" "f$i.*$float_register" "info reg f$i"
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
for {set i 0} {$i < 32} {incr i 1} {
|
102 |
|
|
gdb_test "info reg vs$i" "vs$i.*$vector_register2" "info reg vs$i (doubleword 1)"
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
# Now run the VR0~VR31/VS32~VS63 tests
|
106 |
|
|
|
107 |
|
|
# 1: Set VR0~VR31 registers and check if it reflects on VS32~VS63.
|
108 |
|
|
for {set i 0} {$i < 32} {incr i 1} {
|
109 |
|
|
for {set j 0} {$j < 4} {incr j 1} {
|
110 |
|
|
send_gdb "set \$vr$i.v4_int32\[$j\] = 1"
|
111 |
|
|
}
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
for {set i 32} {$i < 64} {incr i 1} {
|
115 |
|
|
gdb_test "info reg vs$i" "vs$i.*$vector_register3" "info reg vs$i"
|
116 |
|
|
}
|
117 |
|
|
# 2: Set VS32~VS63 registers and check if it reflects on VR0~VR31.
|
118 |
|
|
for {set i 32} {$i < 64} {incr i 1} {
|
119 |
|
|
for {set j 0} {$j < 4} {incr j 1} {
|
120 |
|
|
send_gdb "set \$vs$i.v4_int32\[$j\] = 1"
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
for {set i 0} {$i < 32} {incr i 1} {
|
125 |
|
|
gdb_test "info reg vr$i" "vr$i.*$vector_register3" "info reg vr$i"
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
set escapedfilename [string_to_regexp ${objdir}/${subdir}/vsx-core.test]
|
129 |
|
|
|
130 |
|
|
set core_supported 0
|
131 |
|
|
|
132 |
|
|
gdb_test_multiple "gcore ${objdir}/${subdir}/vsx-core.test" \
|
133 |
|
|
"Save a VSX-enabled corefile" \
|
134 |
|
|
{
|
135 |
|
|
-re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
|
136 |
|
|
pass "Save a VSX-enabled corefile"
|
137 |
|
|
global core_supported
|
138 |
|
|
set core_supported 1
|
139 |
|
|
}
|
140 |
|
|
-re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
|
141 |
|
|
unsupported "Save a VSX-enabled corefile"
|
142 |
|
|
global core_supported
|
143 |
|
|
set core_supported 0
|
144 |
|
|
}
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
if {!$core_supported} {
|
148 |
|
|
return -1
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
gdb_exit
|
152 |
|
|
gdb_start
|
153 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
154 |
|
|
gdb_load ${binfile}
|
155 |
|
|
|
156 |
|
|
gdb_test_multiple "core ${objdir}/${subdir}/vsx-core.test" \
|
157 |
|
|
"re-load generated corefile" \
|
158 |
|
|
{
|
159 |
|
|
-re ".* is not a core dump:.*$gdb_prompt $" {
|
160 |
|
|
fail "re-load generated corefile (bad file format)"
|
161 |
|
|
# No use proceeding from here.
|
162 |
|
|
return;
|
163 |
|
|
}
|
164 |
|
|
-re ".*: No such file or directory.*$gdb_prompt $" {
|
165 |
|
|
fail "re-load generated corefile (file not found)"
|
166 |
|
|
# No use proceeding from here.
|
167 |
|
|
return;
|
168 |
|
|
}
|
169 |
|
|
-re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
|
170 |
|
|
fail "re-load generated corefile (incomplete note section)"
|
171 |
|
|
}
|
172 |
|
|
-re "Core was generated by .*$gdb_prompt $" {
|
173 |
|
|
pass "re-load generated corefile"
|
174 |
|
|
}
|
175 |
|
|
-re ".*$gdb_prompt $" {
|
176 |
|
|
fail "re-load generated corefile"
|
177 |
|
|
}
|
178 |
|
|
timeout {
|
179 |
|
|
fail "re-load generated corefile (timeout)"
|
180 |
|
|
}
|
181 |
|
|
}
|
182 |
|
|
|
183 |
|
|
for {set i 0} {$i < 32} {incr i 1} {
|
184 |
|
|
gdb_test "info reg vs$i" "vs$i.*$vector_register2" "Restore vs$i from core file"
|
185 |
|
|
}
|
186 |
|
|
|
187 |
|
|
for {set i 32} {$i < 64} {incr i 1} {
|
188 |
|
|
gdb_test "info reg vs$i" "vs$i.*$vector_register3" "Restore vs$i from core file"
|
189 |
|
|
}
|