1# Copyright (C) 2002, 2003 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 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# 29# This file uses altivec-abi.c for input. 30# 31 32set prms_id 0 33set bug_id 0 34 35if ![istarget "powerpc-*altivec"] then { 36 verbose "Skipping altivec abi tests." 37 return 38} 39 40set testfile "altivec-abi" 41set binfile ${objdir}/${subdir}/${testfile} 42set srcfile ${testfile}.c 43 44if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable {debug additional_flags=-w}] != "" } { 45 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." 46} 47 48gdb_start 49gdb_reinitialize_dir $srcdir/$subdir 50gdb_load ${binfile} 51 52# 53# Run to `main' where we begin our tests. 54# 55 56if ![runto_main] then { 57 gdb_suppress_tests 58} 59 60gdb_test "b marker" "Breakpoint 2 at.*file.*altivec-abi.c, line \[0-9\]+." "break marker" 61gdb_test "continue" "Breakpoint 2.*marker.*altivec-abi.c.*" "continue to marker" 62gdb_test "finish" "Run till exit from .0.*in marker.*at.*altivec-abi.c.*main \\(\\) at.*altivec-abi.c.*result = vec_func \\(vshort,.*goes in v2.*" "back to main (1)" 63 64# now all the arguments of vec_fun are initialized 65 66set 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.." 67 68set pattern1 $pattern 69append pattern1 " at.*altivec-abi.c.*vint_res = vec_add.*vint_f, intv_on_stack_f.;" 70 71# Now let's call the function. This function has > 12 args, 72# the last one will go on the stack. 73gdb_test "p vec_func(vshort,vushort,vint,vuint,vchar,vuchar,vfloat,x,y,a,b,c,intv_on_stack)" \ 74".\[0-9\]+ = .2, 2, 2, 2." "call inferior function with vectors (1) " 75 76# Let's call the function again with dummy arguments. This is to clean 77# up the contents of the vector registers before the next call. 78gdb_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)" \ 79".\[0-9\]+ = .0, 0, 0, 0." "call inferior function with vectors (2) " 80 81# Let's step into the function, to see if the args are printed correctly. 82gdb_test "step" \ 83 $pattern1 \ 84 "step into vec_fun" 85 86set pattern2 $pattern 87append pattern2 " at.*altivec-abi.c.*in main.*result = vec_func .vshort,.*goes in v2.*Value returned is.*= .2, 2, 2, 2." 88 89# Let's see if the result is returned correctly. 90gdb_test "finish" \ 91 "Run till exit from .0.*$pattern2" \ 92 "vector value returned correctly" 93 94# can we print the args correctly for this function? 95gdb_test "break struct_of_vector_func" "" "" 96 97set 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.*" 98 99gdb_test "continue" \ 100 "Breakpoint 3, $pattern.*vector_struct.vshort1 = vec_add .vector_struct.vshort1, vector_struct.vshort2.;" \ 101 "continue to struct_of_vector_func" 102 103gdb_test "finish" \ 104 "Run till exit from .0 $pattern\[ \r\n\]+main.*altivec-abi.c.*array_of_vector_func.*" \ 105 "back to main (2)" 106 107gdb_test "step" "" "step into array_of_vector_func" 108gdb_test "p matrix\[0\]" ".*= .1, 2, 3, 4, 5, 6, 7, 8." "print first vector" 109gdb_test "p matrix\[1\]" ".*= .11, 12, 13, 14, 15, 16, 17, 18." "print second vector" 110gdb_test "p matrix\[2\]" ".*= .21, 22, 23, 24, 25, 26, 27, 28." "print third vector" 111gdb_test "p matrix\[3\]" ".*= .31, 32, 33, 34, 35, 36, 37, 38." "print fourth vector" 112 113