This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] improve decisions about running vmx tests
- From: Janis Johnson <janis187 at us dot ibm dot com>
- To: Janis Johnson <janis187 at us dot ibm dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 22 Apr 2004 16:57:38 -0700
- Subject: Re: [patch] improve decisions about running vmx tests
- References: <20040421222251.GB27578@us.ibm.com>
Here's an updated version which I believe addresses all of the concerns
that were brought up with yesterday's version. In particular, the
names of the temporary files now include the pid so they'll be unique
for each testsuite that uses these tests. If this looks like a good
solution to that issue then I'll submit a separate patch for the other
tmp.c and tmp.x files in target-supports.exp. It turns out that puts
already adds a newline, so I removed the extra ones.
2004-04-22 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 22 Apr 2004 23:49:08 -0000
@@ -268,3 +268,61 @@ 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 containing VMX
+ # instructions. Include the current process ID in the file
+ # names to prevent conflicts with invocations for multiple
+ # testsuites.
+
+ set p [pid]
+ regsub "xxx" "tmp_xxx.c" $p sname
+ regsub "xxx" "tmp_xxx.x" $p xname
+ regsub "xxx" "./tmp_xxx.x" $p dxname
+
+ set f [open $sname "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" 2
+ set lines [${tool}_target_compile $sname $xname executable ""]
+ file delete $sname
+
+ if [string match "" $lines] then {
+ # No error message, compilation succeeded.
+ set result [${tool}_load $dxname "" ""]
+ set status [lindex $result 0]
+ file delete $xname
+ 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 22 Apr 2004 23:49:08 -0000
@@ -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,13 +33,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]] \