[gcc(refs/users/marxin/heads/parse-opt-and-target-opts)] Come up with NewTargetVariable.

Martin Liska marxin@gcc.gnu.org
Thu Mar 4 15:11:58 GMT 2021


https://gcc.gnu.org/g:9149a2990d4af228488abf9681fcb5ba44e0e781

commit 9149a2990d4af228488abf9681fcb5ba44e0e781
Author: Martin Liska <mliska@suse.cz>
Date:   Thu Mar 4 11:38:54 2021 +0100

    Come up with NewTargetVariable.

Diff:
---
 gcc/config/i386/i386-options.c |  2 ++
 gcc/config/i386/i386.opt       |  6 +++---
 gcc/opt-read.awk               | 21 +++++++++++++++++++++
 gcc/optc-save-gen.awk          | 10 +++++++++-
 gcc/opth-gen.awk               |  5 +++++
 5 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c
index 12349c9f046..7a0282f29d2 100644
--- a/gcc/config/i386/i386-options.c
+++ b/gcc/config/i386/i386-options.c
@@ -2888,6 +2888,7 @@ ix86_set_current_function (tree fndecl)
       else
 	TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
     }
+  /* FIXME
   else if (flag_unsafe_math_optimizations
 	   != TREE_TARGET_OPTION (new_tree)->x_ix86_unsafe_math_optimizations
 	   || (flag_excess_precision
@@ -2906,6 +2907,7 @@ ix86_set_current_function (tree fndecl)
       else
 	TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
     }
+    */
   ix86_previous_fndecl = fndecl;
 
   static bool prev_no_caller_saved_registers;
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index 4c9137eb4ee..f76008c5c5a 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -56,7 +56,7 @@ TargetVariable
 enum excess_precision ix86_excess_precision = EXCESS_PRECISION_DEFAULT
 
 ;; Similarly for flag_unsafe_math_optimizations.
-TargetVariable
+NewTargetVariable
 bool ix86_unsafe_math_optimizations = false
 
 ;; Definitions to add to the cl_target_option structure
@@ -960,14 +960,14 @@ mstack-protector-guard-reg=
 NewTarget RejectNegative Joined Var(ix86_stack_protector_guard_reg_str) PerFunction
 Use the given base register for addressing the stack-protector guard.
 
-TargetVariable
+NewTargetVariable
 addr_space_t ix86_stack_protector_guard_reg = ADDR_SPACE_GENERIC
 
 mstack-protector-guard-offset=
 NewTarget RejectNegative Joined Integer Var(ix86_stack_protector_guard_offset_str) PerFunction
 Use the given offset for addressing the stack-protector guard.
 
-TargetVariable
+NewTargetVariable
 HOST_WIDE_INT ix86_stack_protector_guard_offset = 0
 
 mstack-protector-guard-symbol=
diff --git a/gcc/opt-read.awk b/gcc/opt-read.awk
index 1a6e3ee1be0..2a23eda781a 100644
--- a/gcc/opt-read.awk
+++ b/gcc/opt-read.awk
@@ -22,8 +22,11 @@ BEGIN {
 	n_opts = 0
 	n_langs = 0
 	n_target_save = 0
+	n_new_target_save = 0
+	n_extra_vars = 0
 	n_extra_vars = 0
 	n_extra_target_vars = 0
+	n_extra_new_target_vars = 0
 	n_extra_masks = 0
 	n_extra_c_includes = 0
 	n_extra_h_includes = 0
@@ -74,6 +77,24 @@ BEGIN {
 			extra_target_var_types[n_extra_target_vars] = type
 			n_extra_target_vars++
 		}
+		else if ($1 == "NewTargetVariable") {
+			extra_vars[n_extra_vars] = $2
+			n_extra_vars++
+
+			var = $2
+			sub(" *=.*", "", var)
+			orig_var = var
+			name = var
+			type = var
+			sub("^.*[ *]", "", name)
+			sub(" *" name "$", "", type)
+			new_target_save_decl[n_new_target_save] = type " x_" name
+			n_new_target_save++
+
+			extra_new_target_vars[n_extra_new_target_vars] = name
+			extra_new_target_var_types[n_extra_new_target_vars] = type
+			n_extra_new_target_vars++
+		}
 		else if ($1 == "HeaderInclude") {
 			extra_h_includes[n_extra_h_includes++] = $2;
 		}
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index ab8f4018105..61d538dca53 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -142,8 +142,12 @@ for (i = 0; i < n_opt_char; i++) {
 	if (var_opt_range[name] != "")
 		print "  gcc_assert (IN_RANGE (opts->x_" name ", " var_opt_range[name] "));";
 }
-
 print "";
+
+for (i = 0; i < n_extra_new_target_vars; i++) {
+	print "  ptr->x_" extra_new_target_vars[i] " = opts->x_" extra_new_target_vars[i] ";";
+}
+
 for (i = 0; i < n_opt_other; i++) {
 	print "  ptr->x_" var_opt_other[i] " = opts->x_" var_opt_other[i] ";";
 }
@@ -252,6 +256,10 @@ print "cl_optimization_restore (struct gcc_options *opts, struct gcc_options *op
 print "			 struct cl_optimization *ptr)";
 print "{";
 
+for (i = 0; i < n_extra_new_target_vars; i++) {
+	print "  opts->x_" extra_new_target_vars[i] " = ptr->x_" extra_new_target_vars[i] ";";
+}
+
 for (i = 0; i < n_opt_other; i++) {
 	print "  opts->x_" var_opt_other[i] " = ptr->x_" var_opt_other[i] ";";
 }
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index 0491525da94..9d80c1867ab 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -172,6 +172,11 @@ for (i = 0; i < n_opts; i++) {
 	}
 }
 
+# FIXME: sort by type - likely
+for (i = 0; i < n_new_target_save; i++) {
+	print "  " new_target_save_decl[i] ";";
+}
+
 for (i = 0; i < n_opt_other; i++) {
 	print "  " var_opt_other[i] ";";
 }


More information about the Gcc-cvs mailing list