Commit | Line | Data |
---|---|---|
0b302171 JB |
1 | # Copyright (C) 2002-2003, 2005, 2007-2012 Free Software Foundation, |
2 | # Inc. | |
57680a24 EZ |
3 | # |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
57680a24 EZ |
7 | # (at your option) any later version. |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
57680a24 | 16 | # |
57680a24 EZ |
17 | |
18 | # Tests for Powerpc AltiVec ABI | |
19 | ||
20 | ||
57680a24 | 21 | # |
dd039bc4 | 22 | # This file uses altivec-abi.c for input. |
57680a24 EZ |
23 | # |
24 | ||
3c95e6af | 25 | if {![istarget "powerpc*"] || [skip_altivec_tests]} then { |
57680a24 EZ |
26 | verbose "Skipping altivec abi tests." |
27 | return | |
28 | } | |
29 | ||
dd039bc4 | 30 | set testfile "altivec-abi" |
57680a24 | 31 | set binfile ${objdir}/${subdir}/${testfile} |
f2dd3617 | 32 | set srcfile ${testfile}.c |
57680a24 | 33 | |
d1779be4 PG |
34 | if [get_compiler_info $binfile] { |
35 | warning "get_compiler failed" | |
36 | return -1 | |
37 | } | |
38 | ||
0f4d39d5 | 39 | proc altivec_abi_tests { prefix extra_flags force_abi } { |
55eddb0f DJ |
40 | global testfile binfile srcfile srcdir subdir |
41 | global gdb_prompt | |
d1779be4 | 42 | |
55eddb0f | 43 | set compile_flags "debug nowarnings $extra_flags" |
57680a24 | 44 | |
55eddb0f DJ |
45 | if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $compile_flags] != "" } { |
46 | untested altivec-abi.exp | |
47 | return -1 | |
48 | } | |
57680a24 | 49 | |
55eddb0f DJ |
50 | if { "$force_abi" == "auto" } { |
51 | # If the toolchain does not record attributes, skip auto-ABI tests. | |
52 | set readelf_program [transform readelf] | |
53 | set result [catch "exec $readelf_program -A $binfile" output] | |
57680a24 | 54 | |
55eddb0f DJ |
55 | if {$result == 0 && ![regexp Tag_GNU_Power_ABI_Vector $output]} { |
56 | untested "ABI not marked" | |
57 | return | |
58 | } | |
59 | } | |
60 | ||
61 | gdb_exit | |
62 | gdb_start | |
63 | gdb_reinitialize_dir $srcdir/$subdir | |
64 | gdb_load ${binfile} | |
65 | ||
66 | # Run to `main' where we begin our tests. | |
67 | if ![runto_main] then { | |
68 | untested altivec-abi.exp | |
69 | return -1 | |
70 | } | |
57680a24 | 71 | |
0d8f9b2c | 72 | gdb_test "set print frame-arguments all" |
55eddb0f | 73 | gdb_test "set powerpc vector-abi $force_abi" |
57680a24 | 74 | |
55eddb0f DJ |
75 | gdb_test "b marker" "Breakpoint 2 at.*file.*altivec-abi.c, line \[0-9\]+." "break marker" |
76 | gdb_test "continue" "Breakpoint 2.*marker.*altivec-abi.c.*" "continue to marker" | |
77 | 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 | 78 | |
55eddb0f | 79 | # now all the arguments of vec_fun are initialized |
57680a24 | 80 | |
2844d6b5 | 81 | 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=.97, 98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 112, 113, 114., vuchar_f=.65, 66, 67, 68, 69, 70, 71, 72, 73, 76, 77, 78, 79, 80, 81, 82., 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=.118, 101, 99, 116, 111, 114, 32, 111, 102, 32, 99, 104, 97, 114, 115, 46., 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 | 82 | |
55eddb0f DJ |
83 | set pattern1 $pattern |
84 | append pattern1 " at.*altivec-abi.c.*vint_res = vec_add.*vint_f, intv_on_stack_f.;" | |
57680a24 | 85 | |
55eddb0f DJ |
86 | # Now let's call the function. This function has > 12 args, |
87 | # the last one will go on the stack. | |
88 | set msg "call inferior function with vectors (1)" | |
89 | gdb_test "p vec_func(vshort,vushort,vint,vuint,vchar,vuchar,vfloat,x,y,a,b,c,intv_on_stack)" \ | |
d6dafb7c UW |
90 | ".\[0-9\]+ = .14, 36, 58, 80." "call inferior function with vectors (1)" |
91 | ||
57680a24 | 92 | |
55eddb0f DJ |
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. | |
95 | 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)" \ | |
96 | ".\[0-9\]+ = .0, 0, 0, 0." "call inferior function with vectors (2)" | |
57680a24 | 97 | |
3cbaedff KW |
98 | # Attempt to take address of the return value of vec_func. |
99 | gdb_test "p &vec_func(vshort,vushort,vint,vuint,vchar,vuchar,vfloat,x,y,a,b,c,intv_on_stack)" \ | |
100 | "Attempt to take address of value not located in memory." \ | |
101 | "Attempt to take address of the return value of vec_func" | |
102 | ||
7d8ac8bb | 103 | # Attempt to assign a value to the return value of vec_func. |
3cbaedff KW |
104 | gdb_test "set variable vec_func(vshort,vushort,vint,vuint,vchar,vuchar,vfloat,x,y,a,b,c,intv_on_stack) = {0,1,2,3}" \ |
105 | "Left operand of assignment is not an lvalue." \ | |
7d8ac8bb | 106 | "Attempt to assign a value to the return value of vec_func" |
3cbaedff | 107 | |
55eddb0f DJ |
108 | # Let's step into the function, to see if the args are printed correctly. |
109 | gdb_test "step" \ | |
110 | $pattern1 \ | |
111 | "step into vec_fun" | |
57680a24 | 112 | |
55eddb0f | 113 | set pattern2 $pattern |
d6dafb7c | 114 | append pattern2 " at.*altivec-abi.c.*main.*result = vec_func .vshort,.*goes in v2.*Value returned is.*= .14, 36, 58, 80." |
57680a24 | 115 | |
55eddb0f | 116 | # Let's see if the result is returned correctly. |
24e9cda0 UW |
117 | set message "vector value returned correctly" |
118 | gdb_test_multiple "finish" $message { | |
119 | -re "Run till exit from .0.*$pattern2.*$gdb_prompt $" { | |
120 | pass $message | |
121 | } | |
122 | -re "Run till exit from .0.*Cannot determine contents.*$gdb_prompt $" { | |
123 | # This happens in those cases where the vector is returned by | |
124 | # reference (generic vectors on 64-bit GNU/Linux). | |
125 | pass $message | |
126 | } | |
127 | } | |
57680a24 | 128 | |
55eddb0f DJ |
129 | # can we print the args correctly for this function? |
130 | gdb_test "break struct_of_vector_func" "" "" | |
57680a24 | 131 | |
55eddb0f | 132 | 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 | 133 | |
55eddb0f DJ |
134 | gdb_test "continue" \ |
135 | "Breakpoint 3, $pattern.*vector_struct.vshort1 = vec_add .vector_struct.vshort1, vector_struct.vshort2.;" \ | |
136 | "continue to struct_of_vector_func" | |
57680a24 | 137 | |
55eddb0f DJ |
138 | gdb_test "finish" \ |
139 | "Run till exit from .0 $pattern\[ \r\n\]+main.*altivec-abi.c.*array_of_vector_func.*" \ | |
140 | "back to main (2)" | |
57680a24 | 141 | |
55eddb0f DJ |
142 | gdb_test "step" "" "step into array_of_vector_func" |
143 | gdb_test "p matrix\[0\]" ".*= .1, 2, 3, 4, 5, 6, 7, 8." "print first vector" | |
144 | gdb_test "p matrix\[1\]" ".*= .11, 12, 13, 14, 15, 16, 17, 18." "print second vector" | |
145 | gdb_test "p matrix\[2\]" ".*= .21, 22, 23, 24, 25, 26, 27, 28." "print third vector" | |
146 | gdb_test "p matrix\[3\]" ".*= .31, 32, 33, 34, 35, 36, 37, 38." "print fourth vector" | |
0f4d39d5 | 147 | } |
55eddb0f DJ |
148 | |
149 | if [test_compiler_info gcc*] { | |
0f4d39d5 PA |
150 | with_test_prefix "default ABI, auto" { |
151 | altivec_abi_tests "additional_flags=-maltivec" "auto" | |
152 | } | |
55eddb0f DJ |
153 | |
154 | # On GNU/Linux, we can mix -mabi=no-altivec and -mabi=altivec. | |
155 | # So test some combinations. | |
156 | if { [istarget "powerpc*-linux*"] } { | |
24e9cda0 UW |
157 | # On 64-bit GNU/Linux with GCC 4.1 and 4.2, -mabi=no-altivec |
158 | # was broken, so skip those tests there. | |
159 | if { ![is_lp64_target] || ![test_compiler_info "gcc-4-\[12\]-*"] } { | |
160 | set binfile ${objdir}/${subdir}/${testfile}-ge-ge | |
0f4d39d5 PA |
161 | with_test_prefix "generic ABI, forced" { |
162 | altivec_abi_tests "additional_flags=-maltivec additional_flags=-mabi=no-altivec" "generic" | |
163 | } | |
24e9cda0 UW |
164 | |
165 | set binfile ${objdir}/${subdir}/${testfile}-ge-auto | |
0f4d39d5 PA |
166 | with_test_prefix "generic ABI, auto" { |
167 | altivec_abi_tests "additional_flags=-maltivec additional_flags=-mabi=no-altivec" "auto" | |
168 | } | |
24e9cda0 | 169 | } |
55eddb0f DJ |
170 | |
171 | set binfile ${objdir}/${subdir}/${testfile}-av-av | |
0f4d39d5 PA |
172 | with_test_prefix "AltiVec ABI, forced" { |
173 | altivec_abi_tests "additional_flags=-maltivec additional_flags=-mabi=altivec" "altivec" | |
174 | } | |
55eddb0f DJ |
175 | |
176 | set binfile ${objdir}/${subdir}/${testfile}-av-auto | |
0f4d39d5 PA |
177 | with_test_prefix "AltiVec ABI, auto" { |
178 | altivec_abi_tests "additional_flags=-maltivec additional_flags=-mabi=altivec" "auto" | |
179 | } | |
55eddb0f DJ |
180 | } |
181 | } elseif [test_compiler_info xlc*] { | |
0f4d39d5 | 182 | altivec_abi_tests "additional_flags=-qaltivec" "auto" |
55eddb0f DJ |
183 | } else { |
184 | warning "unknown compiler" | |
185 | return -1 | |
186 | } |