+# Return a 1 if I don't even want to try to test FORTRAN.
+
+proc skip_fortran_tests {} {
+ return 0
+}
+
+# Return a 1 if we should skip shared library tests.
+
+proc skip_shlib_tests {} {
+ # Run the shared library tests on native systems.
+ if {[isnative]} {
+ return 0
+ }
+
+ # An abbreviated list of remote targets where we should be able to
+ # run shared library tests.
+ if {([istarget *-*-linux*]
+ || [istarget *-*-*bsd*]
+ || [istarget *-*-solaris2*]
+ || [istarget arm*-*-symbianelf*]
+ || [istarget *-*-mingw*]
+ || [istarget *-*-cygwin*]
+ || [istarget *-*-pe*])} {
+ return 0
+ }
+
+ return 1
+}
+
+# Run a test on the target to see if it supports vmx hardware. Return 0 if so,
+# 1 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
+
+proc skip_altivec_tests {} {
+ global skip_vmx_tests_saved
+ global srcdir subdir gdb_prompt
+
+ # Use the cached value, if it exists.
+ set me "skip_altivec_tests"
+ if [info exists skip_vmx_tests_saved] {
+ verbose "$me: returning saved $skip_vmx_tests_saved" 2
+ return $skip_vmx_tests_saved
+ }
+
+ # Some simulators are known to not support VMX instructions.
+ if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
+ verbose "$me: target known to not support VMX, returning 1" 2
+ return [set skip_vmx_tests_saved 1]
+ }
+
+ # Make sure we have a compiler that understands altivec.
+ set compile_flags {debug nowarnings}
+ if [get_compiler_info not-used] {
+ warning "Could not get compiler info"
+ return 1
+ }
+ if [test_compiler_info gcc*] {
+ set compile_flags "$compile_flags additional_flags=-maltivec"
+ } elseif [test_compiler_info xlc*] {
+ set compile_flags "$compile_flags additional_flags=-qaltivec"
+ } else {
+ verbose "Could not compile with altivec support, returning 1" 2
+ return 1
+ }
+
+ # Set up, compile, and execute a test program containing VMX instructions.
+ # Include the current process ID in the file names to prevent conflicts
+ # with invocations for multiple testsuites.
+ set src vmx[pid].c
+ set exe vmx[pid].x
+
+ set f [open $src "w"]
+ puts $f "int main() {"
+ puts $f "#ifdef __MACH__"
+ puts $f " asm volatile (\"vor v0,v0,v0\");"
+ puts $f "#else"
+ puts $f " asm volatile (\"vor 0,0,0\");"
+ puts $f "#endif"
+ puts $f " return 0; }"
+ close $f
+
+ verbose "$me: compiling testfile $src" 2
+ set lines [gdb_compile $src $exe executable $compile_flags]
+ file delete $src
+
+ if ![string match "" $lines] then {
+ verbose "$me: testfile compilation failed, returning 1" 2
+ return [set skip_vmx_tests_saved 1]
+ }
+
+ # No error message, compilation succeeded so now run it via gdb.
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load "$exe"
+ gdb_run_cmd
+ gdb_expect {
+ -re ".*Illegal instruction.*${gdb_prompt} $" {
+ verbose -log "\n$me altivec hardware not detected"
+ set skip_vmx_tests_saved 1
+ }
+ -re ".*Program exited normally.*${gdb_prompt} $" {
+ verbose -log "\n$me: altivec hardware detected"
+ set skip_vmx_tests_saved 0
+ }
+ default {
+ warning "\n$me: default case taken"
+ set skip_vmx_tests_saved 1
+ }
+ }
+ gdb_exit
+ remote_file build delete $exe
+
+ verbose "$me: returning $skip_vmx_tests_saved" 2
+ return $skip_vmx_tests_saved
+}
+
+# Run a test on the target to see if it supports vmx hardware. Return 0 if so,
+# 1 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
+
+proc skip_vsx_tests {} {
+ global skip_vsx_tests_saved
+ global srcdir subdir gdb_prompt
+
+ # Use the cached value, if it exists.
+ set me "skip_vsx_tests"
+ if [info exists skip_vsx_tests_saved] {
+ verbose "$me: returning saved $skip_vsx_tests_saved" 2
+ return $skip_vsx_tests_saved
+ }
+
+ # Some simulators are known to not support Altivec instructions, so
+ # they won't support VSX instructions as well.
+ if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
+ verbose "$me: target known to not support VSX, returning 1" 2
+ return [set skip_vsx_tests_saved 1]
+ }
+
+ # Make sure we have a compiler that understands altivec.
+ set compile_flags {debug nowarnings quiet}
+ if [get_compiler_info not-used] {
+ warning "Could not get compiler info"
+ return 1
+ }
+ if [test_compiler_info gcc*] {
+ set compile_flags "$compile_flags additional_flags=-mvsx"
+ } elseif [test_compiler_info xlc*] {
+ set compile_flags "$compile_flags additional_flags=-qvsx"
+ } else {
+ verbose "Could not compile with vsx support, returning 1" 2
+ return 1
+ }
+
+ set src vsx[pid].c
+ set exe vsx[pid].x
+
+ set f [open $src "w"]
+ puts $f "int main() {"
+ puts $f "#ifdef __MACH__"
+ puts $f " asm volatile (\"lxvd2x v0,v0,v0\");"
+ puts $f "#else"
+ puts $f " asm volatile (\"lxvd2x 0,0,0\");"
+ puts $f "#endif"
+ puts $f " return 0; }"
+ close $f
+
+ verbose "$me: compiling testfile $src" 2
+ set lines [gdb_compile $src $exe executable $compile_flags]
+ file delete $src
+
+ if ![string match "" $lines] then {
+ verbose "$me: testfile compilation failed, returning 1" 2
+ return [set skip_vsx_tests_saved 1]
+ }
+
+ # No error message, compilation succeeded so now run it via gdb.
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load "$exe"
+ gdb_run_cmd
+ gdb_expect {
+ -re ".*Illegal instruction.*${gdb_prompt} $" {
+ verbose -log "\n$me VSX hardware not detected"
+ set skip_vsx_tests_saved 1
+ }
+ -re ".*Program exited normally.*${gdb_prompt} $" {
+ verbose -log "\n$me: VSX hardware detected"
+ set skip_vsx_tests_saved 0
+ }
+ default {
+ warning "\n$me: default case taken"
+ set skip_vsx_tests_saved 1
+ }
+ }
+ gdb_exit
+ remote_file build delete $exe
+
+ verbose "$me: returning $skip_vsx_tests_saved" 2
+ return $skip_vsx_tests_saved
+}
+