Switch the license of all .exp files to GPLv3.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / altivec-abi.exp
1 # Copyright (C) 2002, 2003, 2005, 2007 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 <http://www.gnu.org/licenses/>.
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
23 if $tracelevel then {
24 strace $tracelevel
25 }
26
27 #
28 # This file uses altivec-abi.c for input.
29 #
30
31 set prms_id 0
32 set bug_id 0
33
34 if {![istarget "powerpc*"] || [skip_altivec_tests]} then {
35 verbose "Skipping altivec abi tests."
36 verbose -log "Skipping altivec abi tests."
37 return
38 }
39
40 set testfile "altivec-abi"
41 set binfile ${objdir}/${subdir}/${testfile}
42 set srcfile ${testfile}.c
43
44 set compile_flags {debug nowarnings}
45 if [get_compiler_info $binfile] {
46 warning "get_compiler failed"
47 return -1
48 }
49
50 if [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
59 if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $compile_flags] != "" } {
60 untested altivec-abi.exp
61 return -1
62 }
63
64 gdb_start
65 gdb_reinitialize_dir $srcdir/$subdir
66 gdb_load ${binfile}
67
68 #
69 # Run to `main' where we begin our tests.
70 #
71
72 if ![runto_main] then {
73 gdb_suppress_tests
74 }
75
76 gdb_test "b marker" "Breakpoint 2 at.*file.*altivec-abi.c, line \[0-9\]+." "break marker"
77 gdb_test "continue" "Breakpoint 2.*marker.*altivec-abi.c.*" "continue to marker"
78 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)"
79
80 # now all the arguments of vec_fun are initialized
81
82 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.."
83
84 set pattern1 $pattern
85 append pattern1 " at.*altivec-abi.c.*vint_res = vec_add.*vint_f, intv_on_stack_f.;"
86
87 # Now let's call the function. This function has > 12 args,
88 # the last one will go on the stack.
89 gdb_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.
94 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)" \
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.
98 gdb_test "step" \
99 $pattern1 \
100 "step into vec_fun"
101
102 set pattern2 $pattern
103 append pattern2 " at.*altivec-abi.c.*main.*result = vec_func .vshort,.*goes in v2.*Value returned is.*= .2, 2, 2, 2."
104
105 # Let's see if the result is returned correctly.
106 gdb_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?
111 gdb_test "break struct_of_vector_func" "" ""
112
113 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.*"
114
115 gdb_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
119 gdb_test "finish" \
120 "Run till exit from .0 $pattern\[ \r\n\]+main.*altivec-abi.c.*array_of_vector_func.*" \
121 "back to main (2)"
122
123 gdb_test "step" "" "step into array_of_vector_func"
124 gdb_test "p matrix\[0\]" ".*= .1, 2, 3, 4, 5, 6, 7, 8." "print first vector"
125 gdb_test "p matrix\[1\]" ".*= .11, 12, 13, 14, 15, 16, 17, 18." "print second vector"
126 gdb_test "p matrix\[2\]" ".*= .21, 22, 23, 24, 25, 26, 27, 28." "print third vector"
127 gdb_test "p matrix\[3\]" ".*= .31, 32, 33, 34, 35, 36, 37, 38." "print fourth vector"
128
This page took 0.033471 seconds and 4 git commands to generate.