From eaabbb005fca70ef46bff0cd83bcadcf7de6fcd9 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 13 Jan 2015 17:30:23 +0100 Subject: [PATCH] Option diff dump is added for target and optimization * ipa-icf.c (sem_function::equals_private): Call new functions cl_target_option_print_diff and cl_optimization_print_diff. * optc-save-gen.awk (cl_target_option_print_diff): New function. (cl_optimization_print_diff): Likewise. * opth-gen.awk: Likewise. M gcc/ChangeLog M gcc/ipa-icf.c M gcc/optc-save-gen.awk M gcc/opth-gen.awk From-SVN: r219542 --- gcc/ChangeLog | 8 +++ gcc/ipa-icf.c | 12 ++-- gcc/optc-save-gen.awk | 133 ++++++++++++++++++++++++++++++++++++++++++ gcc/opth-gen.awk | 6 ++ 4 files changed, 151 insertions(+), 8 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 491a6379ed7..01f6c6d6b91 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-01-13 Martin Liska + + * ipa-icf.c (sem_function::equals_private): Call new functions + cl_target_option_print_diff and cl_optimization_print_diff. + * optc-save-gen.awk (cl_target_option_print_diff): New function. + (cl_optimization_print_diff): Likewise. + * opth-gen.awk: Likewise. + 2015-01-13 Richard Sandiford * config/aarch64/aarch64.md (subsi3, *subsi3_uxtw, subdi3) diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index 9e2dea5397d..fb3a18924db 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -445,10 +445,8 @@ sem_function::equals_private (sem_item *item, { if (dump_file && (dump_flags & TDF_DETAILS)) { - fprintf (dump_file, "Source target flags\n"); - cl_target_option_print (dump_file, 2, tar1); - fprintf (dump_file, "Target target flags\n"); - cl_target_option_print (dump_file, 2, tar2); + fprintf (dump_file, "target flags difference"); + cl_target_option_print_diff (dump_file, 2, tar1, tar2); } return return_false_with_msg ("Target flags are different"); @@ -466,10 +464,8 @@ sem_function::equals_private (sem_item *item, { if (dump_file && (dump_flags & TDF_DETAILS)) { - fprintf (dump_file, "Source optimization flags\n"); - cl_optimization_print (dump_file, 2, opt1); - fprintf (dump_file, "Target optimization flags\n"); - cl_optimization_print (dump_file, 2, opt2); + fprintf (dump_file, "optimization flags difference"); + cl_optimization_print_diff (dump_file, 2, opt1, opt2); } return return_false_with_msg ("optimization flags are different"); diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk index cce3042783e..c773213ddcf 100644 --- a/gcc/optc-save-gen.awk +++ b/gcc/optc-save-gen.awk @@ -243,6 +243,69 @@ for (i = 0; i < n_opt_char; i++) { print "}"; +print ""; +print "/* Print different optimization variables from structures provided as arguments. */"; +print "void"; +print "cl_optimization_print_diff (FILE *file,"; +print " int indent_to,"; +print " struct cl_optimization *ptr1,"; +print " struct cl_optimization *ptr2)"; +print "{"; + +print " fputs (\"\\n\", file);"; +for (i = 0; i < n_opt_other; i++) { + print " if (ptr1->x_" var_opt_other[i] " != ptr2->x_" var_opt_other[i] ")"; + print " fprintf (file, \"%*s%s (%#lx/%#lx)\\n\","; + print " indent_to, \"\","; + print " \"" var_opt_other[i] "\","; + print " (unsigned long)ptr1->x_" var_opt_other[i] ","; + print " (unsigned long)ptr2->x_" var_opt_other[i] ");"; + print ""; +} + +for (i = 0; i < n_opt_int; i++) { + print " if (ptr1->x_" var_opt_int[i] " != ptr2->x_" var_opt_int[i] ")"; + print " fprintf (file, \"%*s%s (%#x/%#x)\\n\","; + print " indent_to, \"\","; + print " \"" var_opt_int[i] "\","; + print " ptr1->x_" var_opt_int[i] ","; + print " ptr2->x_" var_opt_int[i] ");"; + print ""; +} + +for (i = 0; i < n_opt_enum; i++) { + print " if (ptr1->x_" var_opt_enum[i] " != ptr2->x_" var_opt_enum[i] ")"; + print " fprintf (file, \"%*s%s (%#x/%#x)\\n\","; + print " indent_to, \"\","; + print " \"" var_opt_enum[i] "\","; + print " (int) ptr1->x_" var_opt_enum[i] ","; + print " (int) ptr2->x_" var_opt_enum[i] ");"; + print ""; +} + +for (i = 0; i < n_opt_short; i++) { + print " if (ptr1->x_" var_opt_short[i] " != ptr2->x_" var_opt_short[i] ")"; + print " fprintf (file, \"%*s%s (%#x/%#x)\\n\","; + print " indent_to, \"\","; + print " \"" var_opt_short[i] "\","; + print " ptr1->x_" var_opt_short[i] ","; + print " ptr2->x_" var_opt_short[i] ");"; + print ""; +} + +for (i = 0; i < n_opt_char; i++) { + print " if (ptr1->x_" var_opt_char[i] " != ptr2->x_" var_opt_char[i] ")"; + print " fprintf (file, \"%*s%s (%#x/%#x)\\n\","; + print " indent_to, \"\","; + print " \"" var_opt_char[i] "\","; + print " ptr1->x_" var_opt_char[i] ","; + print " ptr2->x_" var_opt_char[i] ");"; + print ""; +} + +print "}"; + + print ""; print "/* Save selected option variables into a structure. */" print "void"; @@ -436,6 +499,76 @@ for (i = 0; i < n_target_char; i++) { print ""; print " if (targetm.target_option.print)"; print " targetm.target_option.print (file, indent, ptr);"; +print "}"; + +print ""; +print "/* Print different target option variables from structures provided as arguments. */"; +print "void"; +print "cl_target_option_print_diff (FILE *file,"; +print " int indent,"; +print " struct cl_target_option *ptr1,"; +print " struct cl_target_option *ptr2)"; +print "{"; + +print " fputs (\"\\n\", file);"; +for (i = 0; i < n_target_other; i++) { + print " if (ptr1->x_" var_target_other[i] " != ptr2->x_" var_target_other[i] ")"; + if (host_wide_int[var_target_other[i]] == "yes") + print " fprintf (file, \"%*s%s (%#\" HOST_WIDE_INT_PRINT \"x/%#\" HOST_WIDE_INT_PRINT \"x)\\n\","; + else + print " fprintf (file, \"%*s%s (%#x/%#x)\\n\","; + print " indent, \"\","; + print " \"" var_target_other[i] "\","; + if (host_wide_int[var_target_other[i]] == "yes") { + print " ptr1->x_" var_target_other[i] ","; + print " ptr2->x_" var_target_other[i] ");"; + } + else { + print " (unsigned long)ptr1->x_" var_target_other[i] ","; + print " (unsigned long)ptr2->x_" var_target_other[i] ");"; + } + print ""; +} + +for (i = 0; i < n_target_enum; i++) { + print " if (ptr1->x_" var_target_enum[i] " != ptr2->x_" var_target_enum[i] ")"; + print " fprintf (file, \"%*s%s (%#x/%#x)\\n\","; + print " indent, \"\","; + print " \"" var_target_enum[i] "\","; + print " ptr1->x_" var_target_enum[i] ","; + print " ptr2->x_" var_target_enum[i] ");"; + print ""; +} + +for (i = 0; i < n_target_int; i++) { + print " if (ptr1->x_" var_target_int[i] " != ptr2->x_" var_target_int[i] ")"; + print " fprintf (file, \"%*s%s (%#x/%#x)\\n\","; + print " indent, \"\","; + print " \"" var_target_int[i] "\","; + print " ptr1->x_" var_target_int[i] ","; + print " ptr2->x_" var_target_int[i] ");"; + print ""; +} + +for (i = 0; i < n_target_short; i++) { + print " if (ptr1->x_" var_target_short[i] " != ptr2->x_" var_target_short[i] ")"; + print " fprintf (file, \"%*s%s (%#x/%#x)\\n\","; + print " indent, \"\","; + print " \"" var_target_short[i] "\","; + print " ptr1->x_" var_target_short[i] ","; + print " ptr2->x_" var_target_short[i] ");"; + print ""; +} + +for (i = 0; i < n_target_char; i++) { + print " if (ptr1->x_" var_target_char[i] " != ptr2->x_" var_target_char[i] ")"; + print " fprintf (file, \"%*s%s (%#x/%#x)\\n\","; + print " indent, \"\","; + print " \"" var_target_char[i] "\","; + print " ptr1->x_" var_target_char[i] ","; + print " ptr2->x_" var_target_char[i] ");"; + print ""; +} print "}"; diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk index 2368aefc83f..bcb0a957eb2 100644 --- a/gcc/opth-gen.awk +++ b/gcc/opth-gen.awk @@ -284,6 +284,9 @@ print ""; print "/* Print optimization variables from a structure. */"; print "extern void cl_optimization_print (FILE *, int, struct cl_optimization *);"; print ""; +print "/* Print different optimization variables from structures provided as arguments. */"; +print "extern void cl_optimization_print_diff (FILE *, int, cl_optimization *ptr1, cl_optimization *ptr2);"; +print ""; print "/* Save selected option variables into a structure. */" print "extern void cl_target_option_save (struct cl_target_option *, struct gcc_options *);"; print ""; @@ -293,6 +296,9 @@ print ""; print "/* Print target option variables from a structure. */"; print "extern void cl_target_option_print (FILE *, int, struct cl_target_option *);"; print ""; +print "/* Print different target option variables from structures provided as arguments. */"; +print "extern void cl_target_option_print_diff (FILE *, int, cl_target_option *ptr1, cl_target_option *ptr2);"; +print ""; print "/* Compare two target option variables from a structure. */"; print "extern bool cl_target_option_eq (const struct cl_target_option *, const struct cl_target_option *);"; print ""; -- 2.30.2