public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org>,
	Richard Biener <rguenther@suse.de>,
	Richard Earnshaw <Richard.Earnshaw@foss.arm.com>,
	"Joseph S. Myers" <joseph@codesourcery.com>
Subject: Re: [PATCH] options: Save and restore opts_set for Optimization and Target options
Date: Sun, 4 Oct 2020 21:16:00 +0200	[thread overview]
Message-ID: <20201004191600.GH2176@tucnak> (raw)
In-Reply-To: <87ft6uwjja.fsf@linux-m68k.org>

On Sun, Oct 04, 2020 at 09:13:29AM +0200, Andreas Schwab wrote:
> This breaks ia64:
> 
> In file included from ./tm.h:23,
>                  from ../../gcc/gencheck.c:23:
> ./options.h:7816:40: error: ISO C++ forbids zero-size array 'explicit_mask' [-Werror=pedantic]
>  7816 |   unsigned HOST_WIDE_INT explicit_mask[0];
>       |                                        ^
> ./options.h:7816:26: error: zero-size array member 'cl_target_option::explicit_mask' not at end of 'struct cl_target_option' [-Werror=pedantic]
>  7816 |   unsigned HOST_WIDE_INT explicit_mask[0];
>       |                          ^~~~~~~~~~~~~
> ./options.h:7812:16: note: in the definition of 'struct cl_target_option'
>  7812 | struct GTY(()) cl_target_option
>       |                ^~~~~~~~~~~~~~~~

Oops, sorry.

The following patch should fix that and should also fix streaming of the
new explicit_mask_* members.
I'll bootstrap/regtest on x86_64-linux and i686-linux tonight, but have no
way to test it on ia64-linux (well, tested that x86_64-linux -> ia64-linux
cross builds cc1 with it).

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

	* opth-gen.awk: Don't emit explicit_mask array if n_target_explicit
	is equal to n_target_explicit_mask.
	* optc-save-gen.awk: Compute has_target_explicit_mask and if false,
	don't emit code iterating over explicit_mask array elements.  Stream
	also explicit_mask_* target members.

--- gcc/opth-gen.awk.jj	2020-10-03 21:21:59.727862692 +0200
+++ gcc/opth-gen.awk	2020-10-04 11:12:51.851906413 +0200
@@ -291,7 +291,10 @@ for (i = 0; i < n_target_char; i++) {
 }
 
 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) "];";
+if (n_target_explicit > n_target_explicit_mask) {
+	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] ";";
--- gcc/optc-save-gen.awk.jj	2020-10-03 21:21:59.728862678 +0200
+++ gcc/optc-save-gen.awk	2020-10-04 21:03:31.619462434 +0200
@@ -689,6 +689,10 @@ for (i = 0; i < n_target_string; i++) {
 if (j != 0) {
 	print "  ptr->explicit_mask[" k "] = mask;";
 }
+has_target_explicit_mask = 0;
+if (j != 0 || k != 0) {
+	has_target_explicit_mask = 1;
+}
 
 print "}";
 
@@ -1075,9 +1079,11 @@ for (i = 0; i < n_target_val; i++) {
 	print "    return false;";
 }
 
-print "  for (size_t i = 0; i < sizeof (ptr1->explicit_mask) / sizeof (ptr1->explicit_mask[0]); i++)";
-print "    if (ptr1->explicit_mask[i] != ptr2->explicit_mask[i])";
-print "      return false;"
+if (has_target_explicit_mask) {
+	print "  for (size_t i = 0; i < sizeof (ptr1->explicit_mask) / sizeof (ptr1->explicit_mask[0]); i++)";
+	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) {
@@ -1121,8 +1127,10 @@ for (i = 0; i < n_target_val; i++) {
 	name = var_target_val[i]
 	print "  hstate.add_hwi (ptr->" name");";
 }
-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]);";
+if (has_target_explicit_mask) {
+	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)
@@ -1159,8 +1167,22 @@ for (i = 0; i < n_target_val; i++) {
 	print "  bp_pack_value (bp, ptr->" name", 64);";
 }
 
-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);";
+if (has_target_explicit_mask) {
+	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);";
+}
+
+for (i = 0; i < n_target_other; i++) {
+	if (var_target_other[i] in var_target_explicit_mask) {
+		print "  bp_pack_value (bp, ptr->explicit_mask_" var_target_other[i] ", 64);";
+	}
+}
+
+for (i = 0; i < n_target_int; i++) {
+	if (var_target_int[i] in var_target_explicit_mask) {
+		print "  bp_pack_value (bp, ptr->explicit_mask_" var_target_int[i] ", 64);";
+	}
+}
 
 print "}";
 
@@ -1188,8 +1210,22 @@ for (i = 0; i < n_target_val; i++) {
 	print "  ptr->" name" = (" var_target_val_type[i] ") bp_unpack_value (bp, 64);";
 }
 
-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);";
+if (has_target_explicit_mask) {
+	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);";
+}
+
+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] " = bp_unpack_value (bp, 64);";
+	}
+}
+
+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] " = bp_unpack_value (bp, 64);";
+	}
+}
 
 print "}";
 


	Jakub


  reply	other threads:[~2020-10-04 19:16 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08  8:45 [PATCH] arm: Fix up arm_override_options_after_change [PR96939] Jakub Jelinek
2020-09-08 22:01 ` Jeff Law
2020-09-10  8:51 ` [PATCH] arm: Fix up arm_override_options_after_change_1 Jakub Jelinek
2020-09-10 14:11   ` Kyrylo Tkachov
2020-09-10 14:58     ` Jeff Law
2020-09-10 15:01     ` Jakub Jelinek
2020-09-10 15:04       ` Kyrylo Tkachov
2020-09-11  7:46 ` [PATCH] arm: Fix up arm_override_options_after_change [PR96939] Christophe Lyon
2020-09-11  9:29   ` Jakub Jelinek
2020-09-13  8:29     ` [PATCH] options: Save and restore opts_set for Optimization and Target options Jakub Jelinek
2020-09-14  6:32       ` Richard Biener
2020-09-14  8:06         ` Christophe Lyon
2020-09-28 19:50       ` Stefan Schulze Frielinghaus
2020-09-28 19:58         ` Jakub Jelinek
2020-09-30  9:32         ` Jakub Jelinek
2020-09-30 11:21           ` Stefan Schulze Frielinghaus
2020-09-30 11:39             ` Jakub Jelinek
2020-09-30 13:24               ` Stefan Schulze Frielinghaus
2020-10-02  8:46                 ` Jakub Jelinek
2020-10-02 14:21                   ` Stefan Schulze Frielinghaus
2020-10-03  8:41                     ` Jakub Jelinek
2020-10-03 18:02                       ` Richard Biener
2020-10-04  7:13                   ` Andreas Schwab
2020-10-04 19:16                     ` Jakub Jelinek [this message]
2020-10-05  7:08                       ` Jakub Jelinek
2020-10-05  7:10                         ` Richard Biener
2020-10-06  9:28                       ` Andreas Schwab
2020-10-06 13:20                         ` [PATCH] options: Avoid unused variable mask warning [PR97305] Jakub Jelinek
2020-10-06 13:32                           ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201004191600.GH2176@tucnak \
    --to=jakub@redhat.com \
    --cc=Richard.Earnshaw@foss.arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=rguenther@suse.de \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).