options, lto: Optimize streaming of optimization nodes

When working on the previous patch, I've noticed that all cl_optimization
fields appart from strings are streamed with bp_pack_value (..., 64); so we
waste quite a lot of space, given that many of the options are just booleans
or char options and there are 450-ish of them.

Fixed by streaming the number of bits the corresponding fields have.
While for char fields we have also range information, except for 3
it is either -128, 127 or 0, 255, so it didn't seem worth it to bother
with using range-ish packing.

2020-09-16  Jakub Jelinek  <jakub@redhat.com>

	* optc-save-gen.awk: In cl_optimization_stream_out use
	bp_pack_var_len_{int,unsigned} instead of bp_pack_value.  In
	cl_optimization_stream_in use bp_unpack_var_len_{int,unsigned}
	instead of bp_unpack_value.  Formatting fix.
This commit is contained in:
Jakub Jelinek 2020-09-16 10:04:32 +02:00
parent bd909071ac
commit d29a7cd6f4

View File

@ -1257,8 +1257,10 @@ for (i = 0; i < n_opt_val; i++) {
otype = var_opt_val_type[i];
if (otype ~ "^const char \\**$")
print " bp_pack_string (ob, bp, ptr->" name", true);";
else if (otype ~ "^unsigned")
print " bp_pack_var_len_unsigned (bp, ptr->" name");";
else
print " bp_pack_value (bp, ptr->" name", 64);";
print " bp_pack_var_len_int (bp, ptr->" name");";
}
print " for (size_t i = 0; i < sizeof (ptr->explicit_mask) / sizeof (ptr->explicit_mask[0]); i++)";
print " bp_pack_value (bp, ptr->explicit_mask[i], 64);";
@ -1274,14 +1276,15 @@ print "{";
for (i = 0; i < n_opt_val; i++) {
name = var_opt_val[i]
otype = var_opt_val_type[i];
if (otype ~ "^const char \\**$")
{
print " ptr->" name" = bp_unpack_string (data_in, bp);";
print " if (ptr->" name")";
print " ptr->" name" = xstrdup (ptr->" name");";
if (otype ~ "^const char \\**$") {
print " ptr->" name" = bp_unpack_string (data_in, bp);";
print " if (ptr->" name")";
print " ptr->" name" = xstrdup (ptr->" name");";
}
else if (otype ~ "^unsigned")
print " ptr->" name" = (" var_opt_val_type[i] ") bp_unpack_var_len_unsigned (bp);";
else
print " ptr->" name" = (" var_opt_val_type[i] ") bp_unpack_value (bp, 64);";
print " ptr->" name" = (" var_opt_val_type[i] ") bp_unpack_var_len_int (bp);";
}
print " for (size_t i = 0; i < sizeof (ptr->explicit_mask) / sizeof (ptr->explicit_mask[0]); i++)";
print " ptr->explicit_mask[i] = bp_unpack_value (bp, 64);";