]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.arch/altivec-abi.exp
Copyright updates for 2007.
[thirdparty/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
5# the Free Software Foundation; either version 2 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, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16#
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19#
20
21# Tests for Powerpc AltiVec ABI
22
23
24if $tracelevel then {
25 strace $tracelevel
26}
27
28#
dd039bc4 29# This file uses altivec-abi.c for input.
57680a24
EZ
30#
31
32set prms_id 0
33set bug_id 0
34
3c95e6af 35if {![istarget "powerpc*"] || [skip_altivec_tests]} then {
57680a24 36 verbose "Skipping altivec abi tests."
3c95e6af 37 verbose -log "Skipping altivec abi tests."
57680a24
EZ
38 return
39}
40
dd039bc4 41set testfile "altivec-abi"
57680a24 42set binfile ${objdir}/${subdir}/${testfile}
f2dd3617 43set srcfile ${testfile}.c
57680a24 44
fc91c6c2 45set compile_flags {debug nowarnings}
d1779be4
PG
46if [get_compiler_info $binfile] {
47 warning "get_compiler failed"
48 return -1
49}
50
51if [test_compiler_info gcc*] {
52 set compile_flags "$compile_flags additional_flags=-maltivec"
53} elseif [test_compiler_info xlc*] {
54 set compile_flags "$compile_flags additional_flags=-qaltivec"
55} else {
56 warning "unknown compiler"
57 return -1
58}
59
60if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $compile_flags] != "" } {
b60f0898
JB
61 untested altivec-abi.exp
62 return -1
57680a24
EZ
63}
64
65gdb_start
66gdb_reinitialize_dir $srcdir/$subdir
67gdb_load ${binfile}
68
69#
70# Run to `main' where we begin our tests.
71#
72
73if ![runto_main] then {
74 gdb_suppress_tests
75}
76
dd039bc4
EZ
77gdb_test "b marker" "Breakpoint 2 at.*file.*altivec-abi.c, line \[0-9\]+." "break marker"
78gdb_test "continue" "Breakpoint 2.*marker.*altivec-abi.c.*" "continue to marker"
1260befa 79gdb_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
80
81# now all the arguments of vec_fun are initialized
82
83set 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.."
84
85set pattern1 $pattern
dd039bc4 86append pattern1 " at.*altivec-abi.c.*vint_res = vec_add.*vint_f, intv_on_stack_f.;"
57680a24
EZ
87
88# Now let's call the function. This function has > 12 args,
89# the last one will go on the stack.
90gdb_test "p vec_func(vshort,vushort,vint,vuint,vchar,vuchar,vfloat,x,y,a,b,c,intv_on_stack)" \
91".\[0-9\]+ = .2, 2, 2, 2." "call inferior function with vectors (1) "
92
93# Let's call the function again with dummy arguments. This is to clean
94# up the contents of the vector registers before the next call.
95gdb_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)" \
96".\[0-9\]+ = .0, 0, 0, 0." "call inferior function with vectors (2) "
97
98# Let's step into the function, to see if the args are printed correctly.
99gdb_test "step" \
100 $pattern1 \
101 "step into vec_fun"
102
103set pattern2 $pattern
1260befa 104append pattern2 " at.*altivec-abi.c.*main.*result = vec_func .vshort,.*goes in v2.*Value returned is.*= .2, 2, 2, 2."
57680a24
EZ
105
106# Let's see if the result is returned correctly.
107gdb_test "finish" \
108 "Run till exit from .0.*$pattern2" \
109 "vector value returned correctly"
110
111# can we print the args correctly for this function?
112gdb_test "break struct_of_vector_func" "" ""
113
dd039bc4 114set 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
115
116gdb_test "continue" \
117 "Breakpoint 3, $pattern.*vector_struct.vshort1 = vec_add .vector_struct.vshort1, vector_struct.vshort2.;" \
118 "continue to struct_of_vector_func"
119
120gdb_test "finish" \
dd039bc4 121 "Run till exit from .0 $pattern\[ \r\n\]+main.*altivec-abi.c.*array_of_vector_func.*" \
57680a24
EZ
122 "back to main (2)"
123
124gdb_test "step" "" "step into array_of_vector_func"
125gdb_test "p matrix\[0\]" ".*= .1, 2, 3, 4, 5, 6, 7, 8." "print first vector"
126gdb_test "p matrix\[1\]" ".*= .11, 12, 13, 14, 15, 16, 17, 18." "print second vector"
127gdb_test "p matrix\[2\]" ".*= .21, 22, 23, 24, 25, 26, 27, 28." "print third vector"
128gdb_test "p matrix\[3\]" ".*= .31, 32, 33, 34, 35, 36, 37, 38." "print fourth vector"
129