]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.arch/altivec-abi.exp
* ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call): Check the selected
[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
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 15#
57680a24
EZ
16
17# Tests for Powerpc AltiVec ABI
18
19
20if $tracelevel then {
21 strace $tracelevel
22}
23
24#
dd039bc4 25# This file uses altivec-abi.c for input.
57680a24
EZ
26#
27
3c95e6af 28if {![istarget "powerpc*"] || [skip_altivec_tests]} then {
57680a24 29 verbose "Skipping altivec abi tests."
3c95e6af 30 verbose -log "Skipping altivec abi tests."
57680a24
EZ
31 return
32}
33
dd039bc4 34set testfile "altivec-abi"
57680a24 35set binfile ${objdir}/${subdir}/${testfile}
f2dd3617 36set srcfile ${testfile}.c
57680a24 37
d1779be4
PG
38if [get_compiler_info $binfile] {
39 warning "get_compiler failed"
40 return -1
41}
42
55eddb0f
DJ
43proc altivec_abi_tests { extra_flags force_abi } {
44 global testfile binfile srcfile srcdir subdir
45 global gdb_prompt
d1779be4 46
55eddb0f 47 set compile_flags "debug nowarnings $extra_flags"
57680a24 48
55eddb0f
DJ
49 if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $compile_flags] != "" } {
50 untested altivec-abi.exp
51 return -1
52 }
57680a24 53
55eddb0f
DJ
54 if { "$force_abi" == "auto" } {
55 # If the toolchain does not record attributes, skip auto-ABI tests.
56 set readelf_program [transform readelf]
57 set result [catch "exec $readelf_program -A $binfile" output]
57680a24 58
55eddb0f
DJ
59 if {$result == 0 && ![regexp Tag_GNU_Power_ABI_Vector $output]} {
60 untested "ABI not marked"
61 return
62 }
63 }
64
65 gdb_exit
66 gdb_start
67 gdb_reinitialize_dir $srcdir/$subdir
68 gdb_load ${binfile}
69
70 # Run to `main' where we begin our tests.
71 if ![runto_main] then {
72 untested altivec-abi.exp
73 return -1
74 }
57680a24 75
55eddb0f 76 gdb_test "set powerpc vector-abi $force_abi"
57680a24 77
55eddb0f
DJ
78 gdb_test "b marker" "Breakpoint 2 at.*file.*altivec-abi.c, line \[0-9\]+." "break marker"
79 gdb_test "continue" "Breakpoint 2.*marker.*altivec-abi.c.*" "continue to marker"
80 gdb_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 81
55eddb0f 82 # now all the arguments of vec_fun are initialized
57680a24 83
55eddb0f 84 set 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.."
57680a24 85
55eddb0f
DJ
86 set pattern1 $pattern
87 append pattern1 " at.*altivec-abi.c.*vint_res = vec_add.*vint_f, intv_on_stack_f.;"
57680a24 88
55eddb0f
DJ
89 # Now let's call the function. This function has > 12 args,
90 # the last one will go on the stack.
91 set msg "call inferior function with vectors (1)"
92 gdb_test "p vec_func(vshort,vushort,vint,vuint,vchar,vuchar,vfloat,x,y,a,b,c,intv_on_stack)" \
93 ".\[0-9\]+ = .2, 2, 2, 2." "call inferior function with vectors (1)"
57680a24 94
55eddb0f
DJ
95 # Let's call the function again with dummy arguments. This is to clean
96 # up the contents of the vector registers before the next call.
97 gdb_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)" \
98 ".\[0-9\]+ = .0, 0, 0, 0." "call inferior function with vectors (2)"
57680a24 99
55eddb0f
DJ
100 # Let's step into the function, to see if the args are printed correctly.
101 gdb_test "step" \
102 $pattern1 \
103 "step into vec_fun"
57680a24 104
55eddb0f
DJ
105 set pattern2 $pattern
106 append pattern2 " at.*altivec-abi.c.*main.*result = vec_func .vshort,.*goes in v2.*Value returned is.*= .2, 2, 2, 2."
57680a24 107
55eddb0f
DJ
108 # Let's see if the result is returned correctly.
109 gdb_test "finish" "Run till exit from .0.*$pattern2" \
110 "vector value returned correctly"
57680a24 111
55eddb0f
DJ
112 # can we print the args correctly for this function?
113 gdb_test "break struct_of_vector_func" "" ""
57680a24 114
55eddb0f 115 set 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 116
55eddb0f
DJ
117 gdb_test "continue" \
118 "Breakpoint 3, $pattern.*vector_struct.vshort1 = vec_add .vector_struct.vshort1, vector_struct.vshort2.;" \
119 "continue to struct_of_vector_func"
57680a24 120
55eddb0f
DJ
121 gdb_test "finish" \
122 "Run till exit from .0 $pattern\[ \r\n\]+main.*altivec-abi.c.*array_of_vector_func.*" \
123 "back to main (2)"
57680a24 124
55eddb0f
DJ
125 gdb_test "step" "" "step into array_of_vector_func"
126 gdb_test "p matrix\[0\]" ".*= .1, 2, 3, 4, 5, 6, 7, 8." "print first vector"
127 gdb_test "p matrix\[1\]" ".*= .11, 12, 13, 14, 15, 16, 17, 18." "print second vector"
128 gdb_test "p matrix\[2\]" ".*= .21, 22, 23, 24, 25, 26, 27, 28." "print third vector"
129 gdb_test "p matrix\[3\]" ".*= .31, 32, 33, 34, 35, 36, 37, 38." "print fourth vector"
130}
131
132if [test_compiler_info gcc*] {
133 set saved_prefix $pf_prefix
134
135 set pf_prefix "${saved_prefix} default ABI, auto:"
136 altivec_abi_tests "additional_flags=-maltivec" "auto"
137
138 # On GNU/Linux, we can mix -mabi=no-altivec and -mabi=altivec.
139 # So test some combinations.
140 if { [istarget "powerpc*-linux*"] } {
141 set binfile ${objdir}/${subdir}/${testfile}-ge-ge
142 set pf_prefix "${saved_prefix} generic ABI, forced:"
143 altivec_abi_tests "additional_flags=-maltivec additional_flags=-mabi=no-altivec" "generic"
144
145 set binfile ${objdir}/${subdir}/${testfile}-av-av
146 set pf_prefix "${saved_prefix} AltiVec ABI, forced:"
147 altivec_abi_tests "additional_flags=-maltivec additional_flags=-mabi=altivec" "altivec"
148
149 set binfile ${objdir}/${subdir}/${testfile}-av-auto
150 set pf_prefix "${saved_prefix} AltiVec ABI, auto:"
151 altivec_abi_tests "additional_flags=-maltivec additional_flags=-mabi=altivec" "auto"
152 }
153} elseif [test_compiler_info xlc*] {
154 altivec_abi_tests "additional_flags=-qaltivec" "auto"
155} else {
156 warning "unknown compiler"
157 return -1
158}