Switch the license of all .exp files to GPLv3.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / altivec-abi.exp
CommitLineData
6aba47ca 1# Copyright (C) 2002, 2003, 2005, 2007 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#
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
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
57680a24
EZ
15#
16# Please email any bugs, comments, and/or additions to this file to:
17# bug-gdb@prep.ai.mit.edu
18#
19
20# Tests for Powerpc AltiVec ABI
21
22
23if $tracelevel then {
24 strace $tracelevel
25}
26
27#
dd039bc4 28# This file uses altivec-abi.c for input.
57680a24
EZ
29#
30
31set prms_id 0
32set bug_id 0
33
3c95e6af 34if {![istarget "powerpc*"] || [skip_altivec_tests]} then {
57680a24 35 verbose "Skipping altivec abi tests."
3c95e6af 36 verbose -log "Skipping altivec abi tests."
57680a24
EZ
37 return
38}
39
dd039bc4 40set testfile "altivec-abi"
57680a24 41set binfile ${objdir}/${subdir}/${testfile}
f2dd3617 42set srcfile ${testfile}.c
57680a24 43
fc91c6c2 44set compile_flags {debug nowarnings}
d1779be4
PG
45if [get_compiler_info $binfile] {
46 warning "get_compiler failed"
47 return -1
48}
49
50if [test_compiler_info gcc*] {
51 set compile_flags "$compile_flags additional_flags=-maltivec"
52} elseif [test_compiler_info xlc*] {
53 set compile_flags "$compile_flags additional_flags=-qaltivec"
54} else {
55 warning "unknown compiler"
56 return -1
57}
58
59if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $compile_flags] != "" } {
b60f0898
JB
60 untested altivec-abi.exp
61 return -1
57680a24
EZ
62}
63
64gdb_start
65gdb_reinitialize_dir $srcdir/$subdir
66gdb_load ${binfile}
67
68#
69# Run to `main' where we begin our tests.
70#
71
72if ![runto_main] then {
73 gdb_suppress_tests
74}
75
dd039bc4
EZ
76gdb_test "b marker" "Breakpoint 2 at.*file.*altivec-abi.c, line \[0-9\]+." "break marker"
77gdb_test "continue" "Breakpoint 2.*marker.*altivec-abi.c.*" "continue to marker"
1260befa 78gdb_test "finish" "Run till exit from .0.*marker.*at.*altivec-abi.c.*main \\(\\) at.*altivec-abi.c.*result = vec_func \\(vshort,.*goes in v2.*" "back to main (1)"
57680a24
EZ
79
80# now all the arguments of vec_fun are initialized
81
82set pattern "vec_func .vshort_f=.111, 222, 333, 444, 555, 666, 777, 888., vushort_f=.100, 200, 300, 400, 500, 600, 700, 800., vint_f=.-10, -20, -30, -40., vuint_f=.1111, 2222, 3333, 4444., vchar_f=.abcdefghilmnopqr., vuchar_f=.ABCDEFGHILMNOPQR., vfloat_f=.1.25, 3.75, 5.5, 1.25., x_f=.1, 2, 3, 4, 5, 6, 7, 8., y_f=.12, 22, 32, 42., a_f=.vector of chars.., b_f=.5.5, 4.5, 3.75, 2.25., c_f=.1.25, 3.5, 5.5, 7.75., intv_on_stack_f=.12, 34, 56, 78.."
83
84set pattern1 $pattern
dd039bc4 85append pattern1 " at.*altivec-abi.c.*vint_res = vec_add.*vint_f, intv_on_stack_f.;"
57680a24
EZ
86
87# Now let's call the function. This function has > 12 args,
88# the last one will go on the stack.
89gdb_test "p vec_func(vshort,vushort,vint,vuint,vchar,vuchar,vfloat,x,y,a,b,c,intv_on_stack)" \
90".\[0-9\]+ = .2, 2, 2, 2." "call inferior function with vectors (1) "
91
92# Let's call the function again with dummy arguments. This is to clean
93# up the contents of the vector registers before the next call.
94gdb_test "p vec_func(vshort_d,vushort_d,vint_d,vuint_d,vchar_d,vuchar_d,vfloat_d,x_d,y_d,a_d,b_d,c_d,intv_on_stack_d)" \
95".\[0-9\]+ = .0, 0, 0, 0." "call inferior function with vectors (2) "
96
97# Let's step into the function, to see if the args are printed correctly.
98gdb_test "step" \
99 $pattern1 \
100 "step into vec_fun"
101
102set pattern2 $pattern
1260befa 103append pattern2 " at.*altivec-abi.c.*main.*result = vec_func .vshort,.*goes in v2.*Value returned is.*= .2, 2, 2, 2."
57680a24
EZ
104
105# Let's see if the result is returned correctly.
106gdb_test "finish" \
107 "Run till exit from .0.*$pattern2" \
108 "vector value returned correctly"
109
110# can we print the args correctly for this function?
111gdb_test "break struct_of_vector_func" "" ""
112
dd039bc4 113set pattern "struct_of_vector_func .vector_struct=.vshort1 = .1, 2, 3, 4, 5, 6, 7, 8., vshort2 = .11, 12, 13, 14, 15, 16, 17, 18., vshort3 = .21, 22, 23, 24, 25, 26, 27, 28., vshort4 = .31, 32, 33, 34, 35, 36, 37, 38... at.*altivec-abi.c.*"
57680a24
EZ
114
115gdb_test "continue" \
116 "Breakpoint 3, $pattern.*vector_struct.vshort1 = vec_add .vector_struct.vshort1, vector_struct.vshort2.;" \
117 "continue to struct_of_vector_func"
118
119gdb_test "finish" \
dd039bc4 120 "Run till exit from .0 $pattern\[ \r\n\]+main.*altivec-abi.c.*array_of_vector_func.*" \
57680a24
EZ
121 "back to main (2)"
122
123gdb_test "step" "" "step into array_of_vector_func"
124gdb_test "p matrix\[0\]" ".*= .1, 2, 3, 4, 5, 6, 7, 8." "print first vector"
125gdb_test "p matrix\[1\]" ".*= .11, 12, 13, 14, 15, 16, 17, 18." "print second vector"
126gdb_test "p matrix\[2\]" ".*= .21, 22, 23, 24, 25, 26, 27, 28." "print third vector"
127gdb_test "p matrix\[3\]" ".*= .31, 32, 33, 34, 35, 36, 37, 38." "print fourth vector"
128
This page took 0.749714 seconds and 4 git commands to generate.