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] committed: cache results for ILP32, LP64 in testsuite


This patch caches the result of a test for the effective target being
ILP32 or LP64 and only tests again when the multilib flags change.
Tested by running the entire testsuite with -m32/-m64 and make -j 4 on
powerpc64-unknown-linux-gnu.  I've checked this in for mainline.

2005-01-24  Janis Johnson  <janis187@us.ibm.com>

	* lib/target-supports.exp (current_target_name): New.
	(check_effective_target_ilp32, check_effective_target_lp64):
	Cache the result to use as long as the current target, with
	multilib flags, remains the same.

Index: gcc/testsuite/lib/target-supports.exp
===================================================================
RCS file: /opt/gcc-cvs/gcc/gcc/testsuite/lib/target-supports.exp,v
retrieving revision 1.38
diff -u -p -r1.38 target-supports.exp
--- gcc/testsuite/lib/target-supports.exp	9 Jan 2005 00:51:31 -0000	1.38
+++ gcc/testsuite/lib/target-supports.exp	20 Jan 2005 21:40:30 -0000
@@ -42,6 +42,16 @@ proc get_compiler_messages {basename typ
     return $lines
 }
 
+proc current_target_name { } {
+    global target_info
+    if [info exists target_info(target,name)] {
+	set answer $target_info(target,name)
+    } else {
+	set answer ""
+    }
+    return $answer
+}
+
 ###############################
 # proc check_weak_available { }
 ###############################
@@ -418,26 +428,74 @@ proc check_alpha_max_hw_available { } {
 
 # Return 1 if we're generating 32-bit code using default options, 0
 # otherwise.
+#
+# When the target name changes, replace the cached result.
 
 proc check_effective_target_ilp32 { } {
-    verbose "check_effective_target_ilp32: compiling source" 2
-    set answer [string match "" [get_compiler_messages ilp32 object {
-	int dummy[(sizeof (int) == 4 && sizeof (void *) == 4 && sizeof (long) == 4 ) ? 1 : -1];
-    }]]
-    verbose "check_effective_target_ilp32: returning $answer" 2
-    return $answer
+    global et_ilp32_saved
+    global et_ilp32_target_name
+
+    if { ![info exists et_ilp32_target_name] } {
+	set et_ilp32_target_name ""
+    }
+
+    # If the target has changed since we set the cached value, clear it.
+    set current_target [current_target_name]
+    if { $current_target != $et_ilp32_target_name } {
+	verbose "check_effective_target_ilp32: `$et_ilp32_target_name' `$current_target'" 2
+	set et_ilp32_target_name $current_target
+	if { [info exists et_ilp32_saved] } {
+	    verbose "check_effective_target_ilp32: removing cached result" 2
+	    unset et_ilp32_saved
+	}
+    }
+
+    if [info exists et_ilp32_saved] {
+	verbose "check-effective_target_ilp32: using cached result" 2
+    } else {
+	verbose "check_effective_target_ilp32: compiling source" 2
+	set et_ilp32_saved [string match "" [get_compiler_messages ilp32 object {
+	    int dummy[(sizeof (int) == 4 && sizeof (void *) == 4 && sizeof (long) == 4 ) ? 1 : -1];
+	}]]
+    }
+    verbose "check_effective_target_ilp32: returning $et_ilp32_saved" 2
+    return $et_ilp32_saved
 }
 
 # Return 1 if we're generating 64-bit code using default options, 0
 # otherwise.
+#
+# When the target name changes, replace the cached result.
 
 proc check_effective_target_lp64 { } {
-    verbose "check_effective_target_lp64: compiling source" 2
-    set answer [string match "" [get_compiler_messages lp64 object {
-	int dummy[(sizeof (int) == 4 && sizeof (void *) == 8 && sizeof (long) == 8 ) ? 1 : -1];
-    }]]
-    verbose "check_effective_target_lp64: returning $answer" 2
-    return $answer
+    global et_lp64_saved
+    global et_lp64_target_name
+
+    if { ![info exists et_lp64_target_name] } {
+	set et_lp64_target_name ""
+    }
+
+    # If the target has changed since we set the cached value, clear it.
+    set current_target [current_target_name]
+    if { $current_target != $et_lp64_target_name } {
+	verbose "check_effective_target_lp64: `$et_lp64_target_name' `$current_target'" 2
+	set et_lp64_target_name $current_target
+	if [info exists et_lp64_saved] {
+	    verbose "check_effective_target_lp64: removing cached result" 2
+	    unset et_lp64_saved
+	}
+    }
+
+    if [info exists et_lp64_saved] {
+	verbose "check_effective_target_lp64: using cached result" 2
+    } else {
+	verbose "check_effective_target_lp64: compiling source" 2
+	set et_lp64_saved [string match "" [get_compiler_messages lp64 object {
+	    int dummy[(sizeof (int) == 4 && sizeof (void *) == 8 && sizeof (long) == 8 ) ? 1 : -1];
+	}]]
+    }
+    verbose "check_effective_target_lp64: returning $et_lp64_saved" 2
+    return $et_lp64_saved
 }
 
 # Return 1 if the target supports hardware vectors of int, 0 otherwise.


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