diff options
Diffstat (limited to 'gcc/optc-save-gen.awk')
-rw-r--r-- | gcc/optc-save-gen.awk | 95 |
1 files changed, 89 insertions, 6 deletions
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk index 1a365fc..6e33a43 100644 --- a/gcc/optc-save-gen.awk +++ b/gcc/optc-save-gen.awk @@ -85,6 +85,7 @@ n_opt_char = 3; n_opt_short = 0; n_opt_int = 0; n_opt_enum = 0; +n_opt_string = 0; n_opt_other = 0; var_opt_char[0] = "optimize"; var_opt_char[1] = "optimize_size"; @@ -123,6 +124,8 @@ for (i = 0; i < n_opts; i++) { else if (otype ~ "^signed +char *$") var_opt_range[name] = "-128, 127" } + else if (otype ~ "^const char \\**$") + var_opt_string[n_opt_string++] = name; else var_opt_other[n_opt_other++] = name; } @@ -155,6 +158,10 @@ for (i = 0; i < n_opt_char; i++) { print " ptr->x_" var_opt_char[i] " = opts->x_" var_opt_char[i] ";"; } +for (i = 0; i < n_opt_string; i++) { + print " ptr->x_" var_opt_string[i] " = opts->x_" var_opt_string[i] ";"; +} + print "}"; print ""; @@ -183,6 +190,10 @@ for (i = 0; i < n_opt_char; i++) { print " opts->x_" var_opt_char[i] " = ptr->x_" var_opt_char[i] ";"; } +for (i = 0; i < n_opt_string; i++) { + print " opts->x_" var_opt_string[i] " = ptr->x_" var_opt_string[i] ";"; +} + print " targetm.override_options_after_change ();"; print "}"; @@ -239,6 +250,15 @@ for (i = 0; i < n_opt_char; i++) { print ""; } +for (i = 0; i < n_opt_string; i++) { + print " if (ptr->x_" var_opt_char[i] ")"; + print " fprintf (file, \"%*s%s (%s)\\n\","; + print " indent_to, \"\","; + print " \"" var_opt_string[i] "\","; + print " ptr->x_" var_opt_string[i] ");"; + print ""; +} + print "}"; print ""; @@ -301,6 +321,19 @@ for (i = 0; i < n_opt_char; i++) { print ""; } +for (i = 0; i < n_opt_string; i++) { + name = var_opt_string[i] + print " if (ptr1->x_" name " != ptr2->x_" name ""; + print " || (!ptr1->x_" name" || !ptr2->x_" name + print " || strcmp (ptr1->x_" name", ptr2->x_" name ")))"; + print " fprintf (file, \"%*s%s (%s/%s)\\n\","; + print " indent_to, \"\","; + print " \"" name "\","; + print " ptr1->x_" name ","; + print " ptr2->x_" name ");"; + print ""; +} + print "}"; @@ -766,32 +799,82 @@ for (i = 0; i < n_opt_val; i++) { if (!var_opt_hash[i]) continue; name = var_opt_val[i] - print " hstate.add_hwi (ptr->" name");"; + otype = var_opt_val_type[i]; + if (otype ~ "^const char \\**$") + { + print " if (ptr->" name")"; + print " hstate.add (ptr->" name", strlen (ptr->" name"));"; + print " else"; + print " hstate.add_int (0);"; + } + else + print " hstate.add_hwi (ptr->" name");"; } print " return hstate.end ();"; print "}"; print ""; +print "/* Compare two optimization options */"; +print "bool"; +print "cl_optimization_option_eq (cl_optimization const *ptr1,"; +print " cl_optimization const *ptr2)"; +print "{"; +for (i = 0; i < n_opt_val; i++) { + if (!var_opt_hash[i]) + continue; + name = var_opt_val[i] + otype = var_opt_val_type[i]; + if (otype ~ "^const char \\**$") + { + print " if (ptr1->" name" != ptr2->" name; + print " && (!ptr1->" name" || !ptr2->" name + print " || strcmp (ptr1->" name", ptr2->" name ")))"; + print " return false;"; + } + else + { + print " if (ptr1->" name" != ptr2->" name ")"; + print " return false;"; + } +} +print " return true;"; +print "}"; + +print ""; print "/* Stream out optimization options */"; print "void"; -print "cl_optimization_stream_out (struct bitpack_d *bp,"; +print "cl_optimization_stream_out (struct output_block *ob,"; +print " struct bitpack_d *bp,"; print " struct cl_optimization *ptr)"; print "{"; for (i = 0; i < n_opt_val; i++) { name = var_opt_val[i] - print " bp_pack_value (bp, ptr->" name", 64);"; + otype = var_opt_val_type[i]; + if (otype ~ "^const char \\**$") + print " bp_pack_string (ob, bp, ptr->" name", true);"; + else + print " bp_pack_value (bp, ptr->" name", 64);"; } print "}"; print ""; print "/* Stream in optimization options */"; print "void"; -print "cl_optimization_stream_in (struct bitpack_d *bp,"; -print " struct cl_optimization *ptr)"; +print "cl_optimization_stream_in (struct data_in *data_in ATTRIBUTE_UNUSED,"; +print " struct bitpack_d *bp ATTRIBUTE_UNUSED,"; +print " struct cl_optimization *ptr ATTRIBUTE_UNUSED)"; print "{"; for (i = 0; i < n_opt_val; i++) { name = var_opt_val[i] - print " ptr->" name" = (" var_opt_val_type[i] ") bp_unpack_value (bp, 64);"; + 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");"; + } + else + print " ptr->" name" = (" var_opt_val_type[i] ") bp_unpack_value (bp, 64);"; } print "}"; } |