diff gcc/opt-functions.awk @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
line wrap: on
line diff
--- a/gcc/opt-functions.awk	Sun Aug 21 07:07:55 2011 +0900
+++ b/gcc/opt-functions.awk	Fri Oct 27 22:46:09 2017 +0900
@@ -1,5 +1,4 @@
-#  Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010
-#  Free Software Foundation, Inc.
+#  Copyright (C) 2003-2017 Free Software Foundation, Inc.
 #  Contributed by Kelley Cook, June 2004.
 #  Original code from Neil Booth, May 2003.
 #
@@ -30,7 +29,9 @@
 # Return nonzero if FLAGS contains a flag matching REGEX.
 function flag_set_p(regex, flags)
 {
-	return (" " flags " ") ~ (" " regex " ")
+    # Ignore the arguments of flags with arguments.
+    gsub ("\\([^)]+\\)", "", flags);
+    return (" " flags " ") ~ (" " regex " ")
 }
 
 # Return STRING if FLAGS contains a flag matching regexp REGEX,
@@ -42,6 +43,16 @@
 	return ""
 }
 
+# Return a field initializer, with trailing comma, for a field that is
+# 1 if FLAGS contains a flag matching REGEX and 0 otherwise.
+function flag_init(regex, flags)
+{
+	if (flag_set_p(regex, flags))
+		return "1 /* " regex " */, "
+	else
+		return "0, "
+}
+
 # If FLAGS contains a "NAME(...argument...)" flag, return the value
 # of the argument.  Return the empty string otherwise.
 function opt_args(name, flags)
@@ -50,10 +61,10 @@
 	if (flags !~ " " name "\\(")
 		return ""
 	sub(".* " name "\\(", "", flags)
-	if (flags ~ "^{")
+	if (flags ~ "^[{]")
 	{
-		sub ("^{", "", flags)
-		sub("}\\).*", "", flags)
+		sub ("^[{]", "", flags)
+		sub ("}\\).*", "", flags)
 	}
 	else
 		sub("\\).*", "", flags)
@@ -86,27 +97,48 @@
 	result = result \
 	  test_flag("Common", flags, " | CL_COMMON") \
 	  test_flag("Target", flags, " | CL_TARGET") \
+	  test_flag("PchIgnore", flags, " | CL_PCH_IGNORE") \
 	  test_flag("Driver", flags, " | CL_DRIVER") \
-	  test_flag("RejectDriver", flags, " | CL_REJECT_DRIVER") \
-	  test_flag("NoDriverArg", flags, " | CL_NO_DRIVER_ARG") \
-	  test_flag("SeparateAlias", flags, " | CL_SEPARATE_ALIAS") \
-	  test_flag("Save", flags, " | CL_SAVE") \
 	  test_flag("Joined", flags, " | CL_JOINED") \
-	  test_flag("JoinedOrMissing", flags, " | CL_JOINED | CL_MISSING_OK") \
+	  test_flag("JoinedOrMissing", flags, " | CL_JOINED") \
 	  test_flag("Separate", flags, " | CL_SEPARATE") \
-	  test_flag("RejectNegative", flags, " | CL_REJECT_NEGATIVE") \
-	  test_flag("UInteger", flags, " | CL_UINTEGER") \
 	  test_flag("Undocumented", flags,  " | CL_UNDOCUMENTED") \
+	  test_flag("NoDWARFRecord", flags,  " | CL_NO_DWARF_RECORD") \
 	  test_flag("Warning", flags,  " | CL_WARNING") \
-	  test_flag("Optimization", flags,  " | CL_OPTIMIZATION") \
-	  test_flag("Report", flags, " | CL_REPORT")
+	  test_flag("(Optimization|PerFunction)", flags,  " | CL_OPTIMIZATION")
+	sub( "^0 \\| ", "", result )
+	return result
+}
+
+# Return bit-field initializers for option flags FLAGS.
+function switch_bit_fields (flags)
+{
+	vn = var_name(flags);
+	if (host_wide_int[vn] == "yes")
+		hwi = "Host_Wide_Int"
+	else
+		hwi = ""
+	result = ""
 	sep_args = opt_args("Args", flags)
-	if (sep_args != "") {
+	if (sep_args == "")
+		sep_args = 0
+	else
 		sep_args--
-		result = result " | (" sep_args \
-		    " << CL_SEPARATE_NARGS_SHIFT)"
-	}
-	sub( "^0 \\| ", "", result )
+	result = result sep_args ", "
+
+	result = result \
+	  flag_init("SeparateAlias", flags) \
+	  flag_init("NegativeAlias", flags) \
+	  flag_init("NoDriverArg", flags) \
+	  flag_init("RejectDriver", flags) \
+	  flag_init("RejectNegative", flags) \
+	  flag_init("JoinedOrMissing", flags) \
+	  flag_init("UInteger", flags) \
+	  flag_init("Host_Wide_Int", hwi) \
+	  flag_init("ToLower", flags) \
+	  flag_init("Report", flags)
+
+	sub(", $", "", result)
 	return result
 }
 
@@ -117,6 +149,17 @@
 	return nth_arg(0, opt_args("Var", flags))
 }
 
+# Return the name of the variable if FLAGS has a HOST_WIDE_INT variable. 
+# Return the empty string otherwise.
+function host_wide_int_var_name(flags)
+{
+	split (flags, array, "[ \t]+")
+	if (array[1] == "HOST_WIDE_INT")
+		return array[2]
+	else
+		return ""
+}
+
 # Return true if the option described by FLAGS has a globally-visible state.
 function global_state_p(flags)
 {
@@ -169,9 +212,17 @@
 {
 	if (flag_set_p("UInteger", flags))
 		return "int "
+	else if (flag_set_p("Enum.*", flags)) {
+		en = opt_args("Enum", flags);
+		return enum_type[en] " "
+	}
 	else if (!flag_set_p("Joined.*", flags) && !flag_set_p("Separate", flags)) {
-		if (flag_set_p(".*Mask.*", flags))
-			return "int "
+		if (flag_set_p(".*Mask.*", flags)) {
+			if (host_wide_int[var_name(flags)] == "yes")
+				return "HOST_WIDE_INT "
+			else
+				return "int "
+		}
 		else
 			return "signed char "
 	}
@@ -224,7 +275,7 @@
 		return "offsetof (struct gcc_options, x_target_flags)"
 	if (opt_args("InverseMask", flags) != "")
 		return "offsetof (struct gcc_options, x_target_flags)"
-	return "-1"
+	return "(unsigned short) -1"
 }
 
 # Given the option called NAME return a sanitized version of its name.
@@ -239,3 +290,75 @@
 {
 	return "OPT_" opt_sanitized_name(name)
 }
+
+# Given the language called NAME return a sanitized version of its name.
+function lang_sanitized_name(name)
+{
+    gsub( "[^" alnum "_]", "X", name )
+    return name
+}
+
+# Search for a valid var_name among all OPTS equal to option NAME.
+# If not found, return "".
+function search_var_name(name, opt_numbers, opts, flags, n_opts)
+{
+    opt_var_name = var_name(flags[opt_numbers[name]]);
+    if (opt_var_name != "") {
+        return opt_var_name;
+    }
+    for (k = 0; k < n_opts; k++) {
+        if (opts[k] == name && var_name(flags[k]) != "") {
+            return var_name(flags[k]);
+        }
+    }
+    return ""
+}
+
+function integer_range_info(range_option, init, option)
+{
+    if (range_option != "") {
+	start = nth_arg(0, range_option);
+	end = nth_arg(1, range_option);
+	if (init != "" && init != "-1" && (init < start || init > end))
+	  print "#error initial value " init " of '" option "' must be in range [" start "," end "]"
+	return start ", " end
+    }
+    else
+        return "-1, -1"
+}
+
+# Handle LangEnabledBy(ENABLED_BY_LANGS, ENABLEDBY_NAME, ENABLEDBY_POSARG,
+# ENABLEDBY_NEGARG). This function does not return anything.
+function lang_enabled_by(enabledby_langs, enabledby_name, enabledby_posarg, enabledby_negarg)
+{
+    n_enabledby_arg_langs = split(enabledby_langs, enabledby_arg_langs, " ");
+    if (enabledby_posarg != "" && enabledby_negarg != "") {
+        with_args = "," enabledby_posarg "," enabledby_negarg
+    } else if (enabledby_posarg == "" && enabledby_negarg == "") {
+        with_args = ""
+    } else {
+        print "#error " opts[i] " LangEnabledBy("enabledby_langs","enabledby_name", " \
+            enabledby_posarg", " enabledby_negargs                  \
+            ") with three arguments, it should have either 2 or 4"
+    }
+
+    n_enabledby_array = split(enabledby_name, enabledby_array, " \\|\\| ");
+    for (k = 1; k <= n_enabledby_array; k++) {
+        enabledby_index = opt_numbers[enabledby_array[k]];
+        if (enabledby_index == "") {
+             print "#error " opts[i] " LangEnabledBy("enabledby_langs","enabledby_name", " \
+                 enabledby_posarg", " enabledby_negargs"), unknown option '" enabledby_name "'"
+        } else {
+            for (j = 1; j <= n_enabledby_arg_langs; j++) {
+                 lang_name = lang_sanitized_name(enabledby_arg_langs[j]);
+                 lang_index = lang_numbers[enabledby_arg_langs[j]];
+                 if (enables[lang_name,enabledby_array[k]] == "") {
+                     enabledby[lang_name,n_enabledby_lang[lang_index]] = enabledby_array[k];
+                     n_enabledby_lang[lang_index]++;
+                 }
+                 enables[lang_name,enabledby_array[k]] \
+                     = enables[lang_name,enabledby_array[k]] opts[i] with_args ";";
+            }
+        }
+    }
+}