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