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]

[RFC] allow effective-target keywords in dg- directive target lists


I would appreciate some guidance here.

The following directives used in GCC tests include an optional
target_list that is the keyword "target" or "xfail" followed by one or
more target triplets.  These lists make it possible to run a test only
for a set of targets or to make a test an expected failure for a set of
targets.  It's possible that this list of directives is not exhaustive.

    { dg-do keyword { target_list } }
    { dg-options { target_list } }
    { dg-error <other stuff> { target_list } lineno }
    { dg-warning <other stuff> { target_list } lineno }
    { dg-bogus <other stuff> { target_list } lineno }
    { dg-output { string } { target_list } } 
    { dg-final { scan-file filename "regexp" { target_list } } }
    { dg-final { scan-file-not filename "regexp" { target_list } } }
    { dg-final { scan-assembler "string" { target_list } } }
    { dg-final { scan-assembler-not "string" { target_list } } }
    { dg-final { scan-dump-tree-times <other stuff> { target_list } } }

In addition, these directives take a required list of one or more target
triplets without a leading keyword.

    { dg-xfail-if msg { targets } { include } { exclude } }
    { dg-skip-if msg { targets } { include } { exclude } }

The recently added directive dg-require-effective-target takes an
effective-target keyword as argument.  These keywords currently include
ilp32, lp64, named_sections, cg_sections, vmx_hw, and some for specific
kinds of vector support.  The effective target can vary for each
multilib or subtarget run of the testsuite.

I'd like to allow an effective-target keyword to be used in place of the
list of targets in the directives listed above.  This isn't as flexible
as I had hoped for marking a test as an expected failure or unsupported,
but it's sufficient since we can define some fairly specific effective
targets when necessary (like "target supports vectors of int but does
not model alignment of vectors when generating 64-bit code").

Is this a reasonable thing to do in the GCC testsuite?

Is it reasonable to define special-purpose effective-target keywords
within a directory of the testsuite, such as keeping very specific
vector capabilities within gcc.dg/vect/vect.exp?

Here's a patch that implements this.

2004-11-18  Janis Johnson  <janis187@us.ibm.com>

	* lib/gcc-dg.exp (dg-process-target): Wrapper for dg function that
	handles effective-target keywords.
	(dg-skip-if): Support effective-target keyword as target list.
	(dg-xfail-if): Ditto.
	* lib/target-supports.exp (is-effective-target): Simplify.
	(is-effective-target-keyword): New.

Index: lib/gcc-dg.exp
===================================================================
RCS file: /opt/gcc-cvs/gcc/gcc/testsuite/lib/gcc-dg.exp,v
retrieving revision 1.44
diff -u -p -r1.44 gcc-dg.exp
--- lib/gcc-dg.exp	17 Nov 2004 17:21:41 -0000	1.44
+++ lib/gcc-dg.exp	18 Nov 2004 18:55:37 -0000
@@ -455,9 +455,16 @@ proc dg-require-effective-target { args 
 
 proc dg-skip-if { args } {
     set args [lreplace $args 0 0]
-    if [check_conditional_xfail $args] {
-	upvar dg-do-what dg-do-what
-	skip_test_and_clear_xfail
+
+    # The target list might be an effective-target keyword, so replace
+    # the original list with "*-*-*" if it is matched.
+    set selector "target [join [lindex $args 1]]"
+    if { [dg-process-target $selector] == "S" } {
+	# The target list matched; now check the flags.
+	if [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]] {
+	    upvar dg-do-what dg-do-what
+	    skip_test_and_clear_xfail
+	}
     }
 }
 
@@ -486,7 +493,7 @@ proc dg-xfail-if { args } {
     set selector "target [join [lindex $args 1]]"
     if { [dg-process-target $selector] == "S" } {
 	global compiler_conditional_xfail_data
-	set compiler_conditional_xfail_data $args
+	set compiler_conditional_xfail_data [lreplace $args 1 1 "*-*-*"]
     }
 }
 
@@ -519,4 +526,53 @@ if { [info procs saved-dg-test] == [list
 	set additional_prunes ""
     }
 }
+
+# Intercept the call to the DejaGnu version of dg-process-target to
+# support use of an effective-target keyword in place of a list of
+# target triplets to xfail or skip a test.
+#
+# selector is one of:
+#    xfail target-triplet-1 ...
+#    xfail effective-target-keyword
+#    target target-triplet-1 ...
+#    target effective-target-keyword
+#
+# For a target list the result is "S" if the target is selected, "N" otherwise.
+# For an xfail list the result is "F" if the target is affected, "P" otherwise.
+
+if { [info procs saved-dg-process-target] == [list] } {
+    rename dg-process-target saved-dg-process-target
+
+    proc dg-process-target { args } {
+        verbose "replacement dg-process-target" 2
+	
+	# Extract the 'what' keyword from the argument list.
+	set selector [string trim [lindex $args 0]]
+	if [regexp "^xfail " $selector] {
+	    set what "xfail"
+	} elseif [regexp "^target " $selector] {
+	    set what "target"
+	} else {
+	    error "syntax error in target selector \"$selector\""
+	}
+
+	# Extract the rest of the list, which might be a keyword.
+	regsub "^${what}" $selector "" rest
+	set rest [string trim $rest]
+
+	if [is-effective-target-keyword $rest] {
+	    # The selector is an effective target keyword.
+	    if [is-effective-target $rest] {
+		return [expr { $what == "xfail" ? "F" : "S" }]
+	    } else {
+		return [expr { $what == "xfail" ? "P" : "N" }]
+	    }
+	}
+
+	# The selector is not an effective-target keyword, so process
+	# the list of target triplets.
+	return [saved-dg-process-target $selector]
+    }
+}
+
 set additional_prunes ""
Index: lib/target-supports.exp
===================================================================
RCS file: /opt/gcc-cvs/gcc/gcc/testsuite/lib/target-supports.exp,v
retrieving revision 1.27
diff -u -p -r1.27 target-supports.exp
--- lib/target-supports.exp	17 Nov 2004 23:47:19 -0000	1.27
+++ lib/target-supports.exp	18 Nov 2004 19:19:30 -0000
@@ -466,17 +466,32 @@ proc check_effective_target_vect_double 
 
 proc is-effective-target { arg } {
     set selected 0
-    switch $arg {
-	"ilp32"  { set selected [check_effective_target_ilp32] }
-	"lp64"   { set selected [check_effective_target_lp64] }
-	"vmx_hw" { set selected [check_vmx_hw_available] }
-	"named_sections" { set selected [check_named_sections_available] }
-	"gc_sections" { set selected [check_gc_sections_available] }
-	"vect_int" { set selected [check_effective_target_vect_int] }
-	"vect_float" { set selected [check_effective_target_vect_float] }
-	"vect_double" { set selected [check_effective_target_vect_double] }
-	default  { error "unknown effective target selector `$arg'" }
+    if { [info procs check_effective_target_${arg}] != [list] } {
+	set selected [check_effective_target_${arg}]
+    } else {
+	switch $arg {
+	  "vmx_hw"         { set selected [check_vmx_hw_available] }
+	  "named_sections" { set selected [check_named_sections_available] }
+	  "gc_sections"    { set selected [check_gc_sections_available] }
+	  default          { error "unknown effective target keyword `$arg'" }
+	}
     }
     verbose "is-effective-target: $arg $selected" 2
     return $selected
+}
+
+# Return 1 if the argument is an effective-target keyword, 0 otherwise.
+
+proc is-effective-target-keyword { arg } {
+    if { [info procs check_effective_target_${arg}] != [list] } {
+	return 1
+    } else {
+	# These have different names for their check_* procs.
+	switch $arg {
+	  "vmx_hw"         { return 1 }
+	  "named_sections" { return 1 }
+	  "gc_sections"    { return 1 }
+	  default          { return 0 }
+	}
+    }
 }


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