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]

small refactoring in opt-functions.awk


Bootstrapped and regression tested. OK?

2010-04-13  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* opt-functions.awk (opt_sanitized_name): New.
	(opt_enum): New.
	* optc-gen.awk: Use it
	* opth-gen.awk: Use it.
Index: gcc/optc-gen.awk
===================================================================
--- gcc/optc-gen.awk	(revision 158227)
+++ gcc/optc-gen.awk	(working copy)
@@ -168,15 +168,11 @@ for (i = 0; i < n_opts; i++) {
 	while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
 		i++;
 	}
 
 	len = length (opts[i]);
-	enum = "OPT_" opts[i]
-	if (opts[i] == "finline-limit=" || opts[i] == "Wlarger-than=" \
-	    || opts[i] == "ftemplate-depth=")
-		enum = enum "eq"
-	gsub ("[^A-Za-z0-9]", "_", enum)
+	enum = opt_enum(opts[i])
 
 	# If this switch takes joined arguments, back-chain all
 	# subsequent switches to it for which it is a prefix.  If
 	# a later switch S is a longer prefix of a switch T, T
 	# will be back-chained to S in a later iteration of this
Index: gcc/opth-gen.awk
===================================================================
--- gcc/opth-gen.awk	(revision 158227)
+++ gcc/opth-gen.awk	(working copy)
@@ -329,17 +329,11 @@ for (i = 0; i < n_opts; i++) {
 		flags[i + 1] = flags[i] " " flags[i + 1];
 		i++;
 	}
 
 	len = length (opts[i]);
-	enum = "OPT_" opts[i]
-	if (opts[i] == "finline-limit=" || opts[i] == "Wlarger-than=" \
-	    || opts[i] == "ftemplate-depth=")
-		enum = enum "eq"
-	if (opts[i] == "gdwarf+")
-		enum = "OPT_gdwarfplus"
-	gsub ("[^A-Za-z0-9]", "_", enum)
+	enum = opt_enum(opts[i])
 
 	# If this switch takes joined arguments, back-chain all
 	# subsequent switches to it for which it is a prefix.  If
 	# a later switch S is a longer prefix of a switch T, T
 	# will be back-chained to S in a later iteration of this
Index: gcc/opt-functions.awk
===================================================================
--- gcc/opt-functions.awk	(revision 158227)
+++ gcc/opt-functions.awk	(working copy)
@@ -192,5 +192,23 @@ function var_ref(name, flags)
 		return "&target_flags"
 	if (opt_args("InverseMask", flags) != "")
 		return "&target_flags"
 	return "0"
 }
+
+# Given the option called NAME return a sanitized version of its name.
+function opt_sanitized_name(name)
+{
+	if (name == "finline-limit=" || name == "Wlarger-than=" \
+	    || name == "ftemplate-depth=")
+		name = name "eq"
+	if (name == "gdwarf+")
+		name = "gdwarfplus"
+	gsub ("[^A-Za-z0-9]", "_", name)
+	return name
+}
+
+# Given the option called NAME return the appropriate enum for it.
+function opt_enum(name)
+{
+	return "OPT_" opt_sanitized_name(name)
+}

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