[PATCH] improve decisions about running vmx tests, take 3

Janis Johnson janis187@us.ibm.com
Fri May 21 10:13:00 GMT 2004


Here's the latest version of the patch to allow using the gcc.dg/vmx
tests for all powerpc* targets except Aix, and to make the default
action depend on whether the target system supports AltiVec hardware.
Tested on powerpc64-unknown-linux-gnu with -m32 and -m64.

OK for mainline?

2004-05-20  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.

--- lib/target-supports.exp.orig	2004-05-20 14:47:56.000000000 -0700
+++ lib/target-supports.exp	2004-05-20 15:58:19.000000000 -0700
@@ -269,3 +269,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
+}
--- gcc.dg/vmx/vmx.exp.orig	2004-05-20 14:52:56.000000000 -0700
+++ gcc.dg/vmx/vmx.exp	2004-05-20 14:53:42.000000000 -0700
@@ -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



More information about the Gcc-patches mailing list