This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] improve decisions about running vmx tests


The new vmx tests are skipped for everything except powerpc*-*-*altivec,
which has a FIXME.  This patch adds a new proc to the testsuite target
supports to determine whether the test target supports Altivec
instructions and changes the VMX test support to determine whether and
how tests are run depending on whether the target supports compiling
and executing Altivec instructions.  Tested on powerpc64-linux with -m32
and -m64 on hardware with and without VMX support, and on i686-linux to
make sure that the tests are skipped.  OK for mainline?

2004-04-21  Janis Johnson  <janis187@us.ibm.com>

	* lib/target-supports.exp (check_vmx_hw_available): New.
	* gcc.dg/vmx/vmx.exp: Use it to determine default action.

Index: lib/target-supports.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/target-supports.exp,v
retrieving revision 1.16
diff -u -p -r1.16 target-supports.exp
--- lib/target-supports.exp	15 Apr 2004 09:50:46 -0000	1.16
+++ lib/target-supports.exp	21 Apr 2004 20:26:41 -0000
@@ -268,3 +268,53 @@ 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
+
+    verbose "check_vmx_hw_available"
+    if [info exists vmx_hw_available_saved] {
+	verbose "check_hw_available  returning saved $vmx_hw_available_saved"
+    } else {
+	set vmx_hw_available_saved 0
+
+	# Some simulators are known to not support VMX instructions.
+	if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
+	    return $vmx_hw_available_saved
+	}
+
+	# Set up, compile, and execute a test program with VMX
+	# instructions.
+
+	set f [open "tmp.c" "w"]
+	puts $f "int main() {\n"
+	puts $f "#ifdef __MACH__\n"
+	puts $f "  asm volatile (\"vor v0,v0,v0\");\n"
+	puts $f "#else\n"
+	puts $f "  asm volatile (\"vor 0,0,0\");\n"
+	puts $f "#endif\n"
+	puts $f "  return 0; }\n"
+	close $f
+
+	verbose "check_vmx_hw_available  compiling testfile" 2
+	set lines [${tool}_target_compile "tmp.c" "tmp.x" executable ""]
+	file delete tmp.c
+
+	if [string match "" $lines] then {
+	    # No error message, compilation succeeded.
+	    set result [${tool}_load "./tmp.x" "" ""]
+	    set status [lindex $result 0]
+	    verbose "testfile status is <$status>" 2
+
+	    if { $status == "pass" } then {
+		set vmx_hw_available_saved 1
+	    }
+	}
+    }
+
+    return $vmx_hw_available_saved
+}
Index: gcc.dg/vmx/vmx.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/vmx/vmx.exp,v
retrieving revision 1.2
diff -u -p -r1.2 vmx.exp
--- gcc.dg/vmx/vmx.exp	20 Apr 2004 19:24:00 -0000	1.2
+++ gcc.dg/vmx/vmx.exp	21 Apr 2004 20:27:04 -0000
@@ -19,9 +19,12 @@
 # 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.
+if {![istarget powerpc*-*-*]} {
+    return
+}
+# Skip these tests for AIX, where Altivec is not yet supported.
+if {[istarget powerpc*-*-aix*]} {
     return
 }
 
@@ -33,13 +36,18 @@ if ![info exists DEFAULT_VMXCFLAGS] then
     set DEFAULT_VMXCFLAGS "-maltivec -mabi=altivec -std=gnu99"
 }
 
-# Default action in this directory is 'run'.
-global dg-do-what-default
-set save-dg-do-what-default ${dg-do-what-default}
-set dg-do-what-default run
-
 # Initialize `dg'.
 dg-init
+
+# 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}
+if { [ check_vmx_hw_available ] } {
+    set dg-do-what-default run
+} else {
+    set dg-do-what-default compile
+}
 
 # Main loop.
 gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]