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  <ja...@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 via email to