===================================================================
@@ -31,6 +31,7 @@ BEGIN {
n_langs = 0
n_target_save = 0
n_extra_vars = 0
+ n_extra_target_vars = 0
quote = "\042"
comma = ","
FS=SUBSEP
@@ -53,6 +54,24 @@ BEGIN {
extra_vars[n_extra_vars] = $2
n_extra_vars++
}
+ else if ($1 == "TargetVariable") {
+ # Combination of TargetSave and Variable
+ 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)
+ target_save_decl[n_target_save] = type " x_" name
+ n_target_save++
+
+ extra_target_vars[n_extra_target_vars] = name
+ n_extra_target_vars++;
+ }
else {
name = opt_args("Mask", $1)
if (name == "") {
@@ -83,6 +102,9 @@ print "#endif /* GCC_DRIVER */"
print ""
have_save = 0;
+if (n_extra_target_vars)
+ have_save = 1
+
print "struct gcc_options global_options =\n{"
for (i = 0; i < n_extra_vars; i++) {
var = extra_vars[i]
@@ -303,6 +325,7 @@ print "{";
n_opt_char = 2;
n_opt_short = 0;
n_opt_int = 0;
+n_opt_enum = 0;
n_opt_other = 0;
var_opt_char[0] = "optimize";
var_opt_char[1] = "optimize_size";
@@ -329,6 +352,9 @@ for (i = 0; i < n_opts; i++) {
else if (otype ~ "^((un)?signed +)?short *$")
var_opt_short[n_opt_short++] = name;
+ else if (otype ~ "^enum +[a-zA-Z0-9_]+ *")
+ var_opt_enum[n_opt_enum++] = name;
+
else if (otype ~ "^((un)?signed +)?char *$") {
var_opt_char[n_opt_char++] = name;
if (otype ~ "^unsigned +char *$")
@@ -352,6 +378,10 @@ for (i = 0; i < n_opt_other; i++) {
print " ptr->x_" var_opt_other[i] " = opts->x_" var_opt_other[i] ";";
}
+for (i = 0; i < n_opt_enum; i++) {
+ print " ptr->x_" var_opt_enum[i] " = opts->x_" var_opt_enum[i] ";";
+}
+
for (i = 0; i < n_opt_int; i++) {
print " ptr->x_" var_opt_int[i] " = opts->x_" var_opt_int[i] ";";
}
@@ -376,6 +406,10 @@ for (i = 0; i < n_opt_other; i++) {
print " opts->x_" var_opt_other[i] " = ptr->x_" var_opt_other[i] ";";
}
+for (i = 0; i < n_opt_enum; i++) {
+ print " ptr->x_" var_opt_enum[i] " = opts->x_" var_opt_enum[i] ";";
+}
+
for (i = 0; i < n_opt_int; i++) {
print " opts->x_" var_opt_int[i] " = ptr->x_" var_opt_int[i] ";";
}
@@ -409,6 +443,15 @@ for (i = 0; i < n_opt_other; i++) {
print "";
}
+for (i = 0; i < n_opt_enum; i++) {
+ print " if (ptr->x_" var_opt_enum[i] ")";
+ print " fprintf (file, \"%*s%s (%#x)\\n\",";
+ print " indent_to, \"\",";
+ print " \"" var_opt_enum[i] "\",";
+ print " ptr->x_" var_opt_enum[i] ");";
+ print "";
+}
+
for (i = 0; i < n_opt_int; i++) {
print " if (ptr->x_" var_opt_int[i] ")";
print " fprintf (file, \"%*s%s (%#x)\\n\",";
@@ -447,6 +490,7 @@ print "{";
n_target_char = 0;
n_target_short = 0;
n_target_int = 0;
+n_target_enum = 0;
n_target_other = 0;
if (have_save) {
@@ -467,6 +511,9 @@ if (have_save) {
else if (otype ~ "^((un)?signed +)?short *$")
var_target_short[n_target_short++] = name;
+ else if (otype ~ "^enum +[_a-zA-Z0-9]+ *$")
+ var_target_enum[n_target_enum++] = name;
+
else if (otype ~ "^((un)?signed +)?char *$") {
var_target_char[n_target_char++] = name;
if (otype ~ "^unsigned +char *$")
@@ -498,10 +545,18 @@ print " if (targetm.target_option.save)
print " targetm.target_option.save (ptr);";
print "";
+for (i = 0; i < n_extra_target_vars; i++) {
+ print " ptr->x_" extra_target_vars[i] " = opts->x_" extra_target_vars[i] ";";
+}
+
for (i = 0; i < n_target_other; i++) {
print " ptr->x_" var_target_other[i] " = opts->x_" var_target_other[i] ";";
}
+for (i = 0; i < n_target_enum; i++) {
+ print " ptr->x_" var_target_enum[i] " = opts->x_" var_target_enum[i] ";";
+}
+
for (i = 0; i < n_target_int; i++) {
print " ptr->x_" var_target_int[i] " = opts->x_" var_target_int[i] ";";
}
@@ -522,10 +577,18 @@ print "void";
print "cl_target_option_restore (struct gcc_options *opts, struct cl_target_option *ptr)";
print "{";
+for (i = 0; i < n_extra_target_vars; i++) {
+ print " opts->x_" extra_target_vars[i] " = ptr->x_" extra_target_vars[i] ";";
+}
+
for (i = 0; i < n_target_other; i++) {
print " opts->x_" var_target_other[i] " = ptr->x_" var_target_other[i] ";";
}
+for (i = 0; i < n_target_enum; i++) {
+ print " opts->x_" var_target_enum[i] " = ptr->x_" var_target_enum[i] ";";
+}
+
for (i = 0; i < n_target_int; i++) {
print " opts->x_" var_target_int[i] " = ptr->x_" var_target_int[i] ";";
}
@@ -564,6 +627,15 @@ for (i = 0; i < n_target_other; i++) {
print "";
}
+for (i = 0; i < n_target_enum; i++) {
+ print " if (ptr->x_" var_target_enum[i] ")";
+ print " fprintf (file, \"%*s%s (%#x)\\n\",";
+ print " indent, \"\",";
+ print " \"" var_target_enum[i] "\",";
+ print " ptr->x_" var_target_enum[i] ");";
+ print "";
+}
+
for (i = 0; i < n_target_int; i++) {
print " if (ptr->x_" var_target_int[i] ")";
print " fprintf (file, \"%*s%s (%#x)\\n\",";
===================================================================
@@ -29,6 +29,7 @@ BEGIN {
n_langs = 0
n_target_save = 0
n_extra_vars = 0
+ n_extra_target_vars = 0
n_extra_masks = 0
FS=SUBSEP
}
@@ -48,6 +49,24 @@ BEGIN {
extra_vars[n_extra_vars] = $2
n_extra_vars++
}
+ else if ($1 == "TargetVariable") {
+ # Combination of TargetSave and Variable
+ 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)
+ target_save_decl[n_target_save] = type " x_" name
+ n_target_save++
+
+ extra_target_vars[n_extra_target_vars] = name
+ n_extra_target_vars++;
+ }
else {
name = opt_args("Mask", $1)
if (name == "") {
@@ -72,6 +91,8 @@ print "#define OPTIONS_H"
print ""
have_save = 0;
+if (n_extra_target_vars)
+ have_save = 1
print "#ifndef GENERATOR_FILE"
print "struct gcc_options\n{"
@@ -87,10 +108,16 @@ for (i = 0; i < n_extra_vars; i++) {
sub(" *" name "$", "", type)
var_seen[name] = 1
print "#ifdef GENERATOR_FILE"
+ sub("^enum +[a-zA-Z0-9_]+ +", "int ", orig_var)
print "extern " orig_var ";"
print "#else"
- print " " type " x_" name ";"
- print "#define " name " global_options.x_" name
+ if (type ~ "^enum +[_a-zA-Z0-9]+ *$") {
+ print " int x_" name ";"
+ print "#define " name " ((" type ")global_options.x_" name ")"
+ } else {
+ print " " type " x_" name ";"
+ print "#define " name " global_options.x_" name
+ }
print "#endif"
}
@@ -146,6 +173,7 @@ print "{";
n_opt_char = 2;
n_opt_short = 0;
n_opt_int = 0;
+n_opt_enum = 0;
n_opt_other = 0;
var_opt_char[0] = "unsigned char x_optimize";
var_opt_char[1] = "unsigned char x_optimize_size";
@@ -170,6 +198,9 @@ for (i = 0; i < n_opts; i++) {
else if (otype ~ "^((un)?signed +)?char *$")
var_opt_char[n_opt_char++] = otype "x_" name;
+ else if (otype ~ "^enum +[a-zA-Z0-9_]+ *$")
+ var_opt_enum[n_opt_enum++] = "int x_" name;
+
else
var_opt_other[n_opt_other++] = otype "x_" name;
}
@@ -179,6 +210,10 @@ for (i = 0; i < n_opt_other; i++) {
print " " var_opt_other[i] ";";
}
+for (i = 0; i < n_opt_enum; i++) {
+ print " " var_opt_enum[i] ";";
+}
+
for (i = 0; i < n_opt_int; i++) {
print " " var_opt_int[i] ";";
}
@@ -202,6 +237,7 @@ print "{";
n_target_char = 0;
n_target_short = 0;
n_target_int = 0;
+n_target_enum = 0;
n_target_other = 0;
for (i = 0; i < n_target_save; i++) {
@@ -214,6 +250,11 @@ for (i = 0; i < n_target_save; i++) {
else if (target_save_decl[i] ~ "^((un)?signed +)?char +[_a-zA-Z0-9]+$")
var_target_char[n_target_char++] = target_save_decl[i];
+ else if (target_save_decl[i] ~ "^enum +[_a-zA-Z0-9]+ +[_a-zA-Z0-9]+$") {
+ var = target_save_decl[i]
+ sub("^enum +[_a-zA-Z0-9]+ +", "int", var)
+ var_target_enum[n_target_enum++] = var
+ }
else
var_target_other[n_target_other++] = target_save_decl[i];
}
@@ -239,6 +280,9 @@ if (have_save) {
else if (otype ~ "^((un)?signed +)?char *$")
var_target_char[n_target_char++] = otype "x_" name;
+ else if (otype ~ "^enum +[_a-zA-Z0-9]+ +[_a-zA-Z0-9]+")
+ var_target_enum[n_target_enum++] = "int x_" name;
+
else
var_target_other[n_target_other++] = otype "x_" name;
}
@@ -251,6 +295,10 @@ for (i = 0; i < n_target_other; i++) {
print " " var_target_other[i] ";";
}
+for (i = 0; i < n_target_enum; i++) {
+ print " " var_target_int[i] ";";
+}
+
for (i = 0; i < n_target_int; i++) {
print " " var_target_int[i] ";";
}
===================================================================
@@ -52,6 +52,20 @@ for variables set in option handlers rat
@code{Var} properties.
@item
+A variable record to define a variable used to store option
+information. These records have two fields: the string
+@samp{TargetVariable}, and a declaration of the type and name of the
+variable, optionally with an initializer (but without any trailing
+@samp{;}). @samp{TargetVariable} are a combination of @samp{Variable}
+and @samp{TargetSave} records in that the variable is defined in the
+@code{gcc_options} structure, but these variables are also stored in
+@code{cl_target_option} structure. The variables are saved in the
+target save code and restored in the target restore code.
+
+records have two fields: the string @samp{TargetSave}, and a
+declaration type to go in the @code{cl_target_option} structure.
+
+@item
An option definition record. These records have the following fields:
@enumerate
@item