options: Fix up opts_set saving/restoring for underlying vars of Mask/InverseMask options

Seems I've missed that set_option has special treatment for
CLVC_BIT_CLEAR/CLVC_BIT_SET.
Which means I'll need to change the generic handling, so that for
global_options_set elements mentioned in CLVC_BIT_* options are treated
differently, instead of using the accumulated bitmasks they'll need to use
their specific bitmask variables during the option saving/restoring.

Here is a patch that implements that.

2020-10-03  Jakub Jelinek  <jakub@redhat.com>

	* opth-gen.awk: For variables referenced in Mask and InverseMask,
	don't use the explicit_mask bitmask array, but add separate
	explicit_mask_* members with the same types as the variables.
	* optc-save-gen.awk: Save, restore, compare and hash the separate
	explicit_mask_* members.
This commit is contained in:
Jakub Jelinek 2020-10-03 21:22:03 +02:00
parent a1f77106ec
commit ce531b1412
2 changed files with 61 additions and 2 deletions

View File

@ -516,6 +516,10 @@ if (have_save) {
var_save_seen[name]++;
otype = var_type_struct(flags[i])
if (opt_args("Mask", flags[i]) != "" \
|| opt_args("InverseMask", flags[i]))
var_target_explicit_mask[name] = 1;
if (otype ~ "^((un)?signed +)?int *$")
var_target_int[n_target_int++] = name;
@ -545,6 +549,7 @@ if (have_save) {
}
} else {
var_target_int[n_target_int++] = "target_flags";
var_target_explicit_mask["target_flags"] = 1;
}
have_assert = 0;
@ -608,6 +613,10 @@ for (i = 0; i < n_extra_target_vars; i++) {
}
for (i = 0; i < n_target_other; i++) {
if (var_target_other[i] in var_target_explicit_mask) {
print " ptr->explicit_mask_" var_target_other[i] " = opts_set->x_" var_target_other[i] ";";
continue;
}
print " if (opts_set->x_" var_target_other[i] ") mask |= HOST_WIDE_INT_1U << " j ";";
j++;
if (j == 64) {
@ -630,6 +639,10 @@ for (i = 0; i < n_target_enum; i++) {
}
for (i = 0; i < n_target_int; i++) {
if (var_target_int[i] in var_target_explicit_mask) {
print " ptr->explicit_mask_" var_target_int[i] " = opts_set->x_" var_target_int[i] ";";
continue;
}
print " if (opts_set->x_" var_target_int[i] ") mask |= HOST_WIDE_INT_1U << " j ";";
j++;
if (j == 64) {
@ -739,6 +752,10 @@ for (i = 0; i < n_extra_target_vars; i++) {
}
for (i = 0; i < n_target_other; i++) {
if (var_target_other[i] in var_target_explicit_mask) {
print " opts_set->x_" var_target_other[i] " = ptr->explicit_mask_" var_target_other[i] ";";
continue;
}
if (j == 64) {
print " mask = ptr->explicit_mask[" k "];";
k++;
@ -761,6 +778,10 @@ for (i = 0; i < n_target_enum; i++) {
}
for (i = 0; i < n_target_int; i++) {
if (var_target_int[i] in var_target_explicit_mask) {
print " opts_set->x_" var_target_int[i] " = ptr->explicit_mask_" var_target_int[i] ";";
continue;
}
if (j == 64) {
print " mask = ptr->explicit_mask[" k "];";
k++;
@ -1058,6 +1079,20 @@ print " for (size_t i = 0; i < sizeof (ptr1->explicit_mask) / sizeof (ptr1->exp
print " if (ptr1->explicit_mask[i] != ptr2->explicit_mask[i])";
print " return false;"
for (i = 0; i < n_target_other; i++) {
if (var_target_other[i] in var_target_explicit_mask) {
print " if (ptr1->explicit_mask_" var_target_other[i] " != ptr2->explicit_mask_" var_target_other[i] ")";
print " return false;";
}
}
for (i = 0; i < n_target_int; i++) {
if (var_target_int[i] in var_target_explicit_mask) {
print " if (ptr1->explicit_mask_" var_target_int[i] " != ptr2->explicit_mask_" var_target_int[i] ")";
print " return false;";
}
}
print " return true;";
print "}";
@ -1088,6 +1123,17 @@ for (i = 0; i < n_target_val; i++) {
}
print " for (size_t i = 0; i < sizeof (ptr->explicit_mask) / sizeof (ptr->explicit_mask[0]); i++)";
print " hstate.add_hwi (ptr->explicit_mask[i]);";
for (i = 0; i < n_target_other; i++) {
if (var_target_other[i] in var_target_explicit_mask)
print " hstate.add_hwi (ptr->explicit_mask_" var_target_other[i] ");";
}
for (i = 0; i < n_target_int; i++) {
if (var_target_int[i] in var_target_explicit_mask)
print " hstate.add_hwi (ptr->explicit_mask_" var_target_int[i] ");";
}
print " return hstate.end ();";
print "}";

View File

@ -209,6 +209,7 @@ n_target_int = 0;
n_target_enum = 0;
n_target_other = 0;
n_target_explicit = n_extra_target_vars;
n_target_explicit_mask = 0;
for (i = 0; i < n_target_save; i++) {
if (target_save_decl[i] ~ "^((un)?signed +)?int +[_" alnum "]+$")
@ -240,6 +241,12 @@ if (have_save) {
var_save_seen[name]++;
n_target_explicit++;
otype = var_type_struct(flags[i])
if (opt_args("Mask", flags[i]) != "" \
|| opt_args("InverseMask", flags[i]))
var_target_explicit_mask[n_target_explicit_mask++] \
= otype "explicit_mask_" name;
if (otype ~ "^((un)?signed +)?int *$")
var_target_int[n_target_int++] = otype "x_" name;
@ -259,6 +266,8 @@ if (have_save) {
} else {
var_target_int[n_target_int++] = "int x_target_flags";
n_target_explicit++;
var_target_explicit_mask[n_target_explicit_mask++] \
= "int explicit_mask_target_flags";
}
for (i = 0; i < n_target_other; i++) {
@ -281,8 +290,12 @@ for (i = 0; i < n_target_char; i++) {
print " " var_target_char[i] ";";
}
print " /* " n_target_explicit " members */";
print " unsigned HOST_WIDE_INT explicit_mask[" int ((n_target_explicit + 63) / 64) "];";
print " /* " n_target_explicit - n_target_explicit_mask " members */";
print " unsigned HOST_WIDE_INT explicit_mask[" int ((n_target_explicit - n_target_explicit_mask + 63) / 64) "];";
for (i = 0; i < n_target_explicit_mask; i++) {
print " " var_target_explicit_mask[i] ";";
}
print "};";
print "";