From 763ee179ed8e563ffb863f8977d9c5a31cdbf0a9 Mon Sep 17 00:00:00 2001 From: Janis Johnson Date: Fri, 28 May 2004 22:31:44 +0000 Subject: [PATCH] target-supports.exp (check_vmx_hw_available): New. 2004-05-28 Janis Johnson * lib/target-supports.exp (check_vmx_hw_available): New. * gcc.dg/vmx/vmx.exp: Use it to determine default action. From-SVN: r82390 --- gcc/testsuite/ChangeLog | 5 ++- gcc/testsuite/gcc.dg/vmx/vmx.exp | 15 ++++--- gcc/testsuite/lib/target-supports.exp | 57 +++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 6 deletions(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7c42703a810..53b52bf058f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,4 +1,7 @@ -2004-05-28 Janis Johnson + + * lib/target-supports.exp (check_vmx_hw_available): New. + * gcc.dg/vmx/vmx.exp: Use it to determine default action. * lib/target-supports.exp (check_alias_available, check_iconv_available, check_named_sections_available): Use diff --git a/gcc/testsuite/gcc.dg/vmx/vmx.exp b/gcc/testsuite/gcc.dg/vmx/vmx.exp index aa376b1d71d..f1b761c7a2a 100644 --- a/gcc/testsuite/gcc.dg/vmx/vmx.exp +++ b/gcc/testsuite/gcc.dg/vmx/vmx.exp @@ -19,9 +19,9 @@ # Load support procs. load_lib gcc-dg.exp -# Only run this test on PowerPC targets with Altivec support. -# For now, that's powerpc*-*-*altivec*. FIXME: generalize. -if {![istarget powerpc*-*-*altivec*]} { +# Skip these tests for non-PowerPC targets and for Aix, where AltiVec +# is not yet supported. +if {![istarget powerpc*-*-*] || [istarget powerpc*-*-aix*]} { return } @@ -33,10 +33,15 @@ if ![info exists DEFAULT_VMXCFLAGS] then { set DEFAULT_VMXCFLAGS "-maltivec -mabi=altivec -std=gnu99" } -# Default action in this directory is 'run'. +# If the target system supports AltiVec instructions, the default action +# for a test is 'run', otherwise it's 'compile'. global dg-do-what-default set save-dg-do-what-default ${dg-do-what-default} -set dg-do-what-default run +if { [check_vmx_hw_available ] } { + set dg-do-what-default run +} else { + set dg-do-what-default compile +} # Initialize `dg'. dg-init diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index aefba1d890c..aee7016bf87 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -280,3 +280,60 @@ proc check_named_sections_available { } { verbose "check_named_sections_available returning $answer" 2 return $answer } + +# Return 1 if the target supports executing AltiVec instructions, 0 +# otherwise. Cache the result. + +proc check_vmx_hw_available { } { + global vmx_hw_available_saved + global tool + + if [info exists vmx_hw_available_saved] { + verbose "check_hw_available returning saved $vmx_hw_available_saved" 2 + } else { + set vmx_hw_available_saved 0 + + # Some simulators are known to not support VMX instructions. + if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } { + verbose "check_hw_available returning 0" 2 + return $vmx_hw_available_saved + } + + # 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 "check_vmx_hw_available compiling testfile $src" 2 + set lines [${tool}_target_compile $src $exe executable ""] + file delete $src + + if [string match "" $lines] then { + # No error message, compilation succeeded. + set result [${tool}_load "./$exe" "" ""] + set status [lindex $result 0] + remote_file build delete $exe + verbose "check_vmx_hw_available testfile status is <$status>" 2 + + if { $status == "pass" } then { + set vmx_hw_available_saved 1 + } + } else { + verbose "check_vmx_hw_availalble testfile compilation failed" 2 + } + } + + return $vmx_hw_available_saved +} -- 2.30.2