lto-streamer-out.c (hash_tree): Use cl_optimization_hash.
authorJan Hubicka <hubicka@ucw.cz>
Sat, 15 Nov 2014 16:53:51 +0000 (17:53 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sat, 15 Nov 2014 16:53:51 +0000 (16:53 +0000)
* lto-streamer-out.c (hash_tree): Use cl_optimization_hash.
* lto-streamer.h (cl_optimization_stream_out, cl_optimization_stream_in): Declare.
* optc-save-gen.awk: Generate cl_optimization LTO streaming and hashing routines.
* opth-gen.awk: Add prototype of cl_optimization_hash.
* tree-streamer-in.c (unpack_ts_optimization): Remove.
(streamer_unpack_tree_bitfields): Use cl_optimization_stream_in.
* tree-streamer-out.c (pack_ts_optimization): Remove.
(streamer_pack_tree_bitfields): Use cl_optimization_stream_out.

From-SVN: r217607

gcc/ChangeLog
gcc/lto-streamer-out.c
gcc/lto-streamer.h
gcc/optc-save-gen.awk
gcc/opth-gen.awk
gcc/tree-streamer-in.c
gcc/tree-streamer-out.c

index 42fe8fa0b686d7191d2435b40478852c322bad61..bb82d0e4743afc5b976a1d21ed899868c3e69dff 100644 (file)
@@ -1,3 +1,14 @@
+2014-11-15  Jan Hubicka <hubicka@ucw.cz>
+
+       * lto-streamer-out.c (hash_tree): Use cl_optimization_hash.
+       * lto-streamer.h (cl_optimization_stream_out, cl_optimization_stream_in): Declare.
+       * optc-save-gen.awk: Generate cl_optimization LTO streaming and hashing routines.
+       * opth-gen.awk: Add prototype of cl_optimization_hash.
+       * tree-streamer-in.c (unpack_ts_optimization): Remove.
+       (streamer_unpack_tree_bitfields): Use cl_optimization_stream_in.
+       * tree-streamer-out.c (pack_ts_optimization): Remove.
+       (streamer_pack_tree_bitfields): Use cl_optimization_stream_out.
+
 2014-11-15  Mircea Namolaru  <mircea.namolaru@inria.fr>
 
        * common.opt (flag_loop_unroll_and_jam): New flag.
index f376a30dac06057691754942dc534487604ee277..ab067274ad720b95bbba942b9343b8af9168becd 100644 (file)
@@ -948,7 +948,7 @@ hash_tree (struct streamer_tree_cache_d *cache, hash_map<tree, hashval_t> *map,
     hstate.add_wide_int (cl_target_option_hash (TREE_TARGET_OPTION (t)));
 
   if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
-    hstate.add (t, sizeof (struct cl_optimization));
+    hstate.add_wide_int (cl_optimization_hash (TREE_OPTIMIZATION (t)));
 
   if (CODE_CONTAINS_STRUCT (code, TS_IDENTIFIER))
     hstate.merge_hash (IDENTIFIER_HASH_VALUE (t));
index 8e5ee628e12f9a05e26f0ac4cdc7955184e175e9..000c147dc5894f80995878db3e70cd8b8bedbc2e 100644 (file)
@@ -844,6 +844,10 @@ void cl_target_option_stream_in (struct data_in *,
                                 struct bitpack_d *,
                                 struct cl_target_option *);
 
+void cl_optimization_stream_out (struct bitpack_d *, struct cl_optimization *);
+
+void cl_optimization_stream_in (struct bitpack_d *, struct cl_optimization *);
+
 
 /* In lto-symtab.c.  */
 extern void lto_symtab_merge_decls (void);
index 861683460ad5364ca7640edf32499dfca92232ff..54c2ed21afce6acaa147b0d284f08ddd9341f2d5 100644 (file)
@@ -551,4 +551,61 @@ for (i = 0; i < n_target_val; i++) {
 
 print "}";
 
+n_opt_val = 2;
+var_opt_val[0] = "x_optimize"
+var_opt_val_type[0] = "char "
+var_opt_val[1] = "x_optimize_size"
+var_opt_val_type[1] = "char "
+for (i = 0; i < n_opts; i++) {
+       if (flag_set_p("Optimization", flags[i])) {
+               name = var_name(flags[i])
+               if(name == "")
+                       continue;
+
+               if(name in var_opt_list_seen)
+                       continue;
+
+               var_opt_list_seen[name]++;
+
+               otype = var_type_struct(flags[i])
+               var_opt_val_type[n_opt_val] = otype;
+               var_opt_val[n_opt_val++] = "x_" name;
+       }
+}
+print "";
+print "/* Hash optimization options  */";
+print "hashval_t";
+print "cl_optimization_hash (struct cl_optimization const *ptr ATTRIBUTE_UNUSED)";
+print "{";
+print "  inchash::hash hstate;";
+for (i = 0; i < n_opt_val; i++) {
+       name = var_opt_val[i]
+       print "  hstate.add_wide_int (ptr->" name");";
+}
+print "  return hstate.end ();";
+print "}";
+
+print "";
+print "/* Stream out optimization options  */";
+print "void";
+print "cl_optimization_stream_out (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);";
+}
+print "}";
+
+print "";
+print "/* Stream in optimization options  */";
+print "void";
+print "cl_optimization_stream_in (struct bitpack_d *bp,";
+print "                           struct cl_optimization *ptr)";
+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);";
+}
+print "}";
 }
index a8a04b789ec0079a61c7e71819ae3908c2998d0d..56e706a48577d425b2ad63f308b4b6c5d49241f6 100644 (file)
@@ -299,6 +299,9 @@ print "";
 print "/* Hash option variables from a structure.  */";
 print "extern hashval_t cl_target_option_hash (const struct cl_target_option *);";
 print "";
+print "/* Hash optimization from a structure.  */";
+print "extern hashval_t cl_optimization_hash (const struct cl_optimization *);";
+print "";
 print "/* Anything that includes tm.h, does not necessarily need this.  */"
 print "#if !defined(GCC_TM_H)"
 print "#include \"input.h\" /* for location_t */"
index c63bc607d8af85a2b85bf46a77cfb834266b8f75..a11a46e168d93f12a87cb80f55f864cddcc6e8e2 100644 (file)
@@ -399,21 +399,6 @@ unpack_ts_translation_unit_decl_value_fields (struct data_in *data_in,
   vec_safe_push (all_translation_units, expr);
 }
 
-/* Unpack a TS_OPTIMIZATION tree from BP into EXPR.  */
-
-static void
-unpack_ts_optimization (struct bitpack_d *bp, tree expr)
-{
-  unsigned i, len;
-  struct cl_optimization *t = TREE_OPTIMIZATION (expr);
-
-  len = sizeof (struct cl_optimization);
-  for (i = 0; i < len; i++)
-    ((unsigned char *)t)[i] = bp_unpack_value (bp, 8);
-  if (bp_unpack_value (bp, 32) != 0x12345678)
-    fatal_error ("cl_optimization size mismatch in LTO reader and writer");
-}
-
 
 /* Unpack all the non-pointer fields of the TS_OMP_CLAUSE
    structure of expression EXPR from bitpack BP.  */
@@ -507,7 +492,7 @@ unpack_value_fields (struct data_in *data_in, struct bitpack_d *bp, tree expr)
     unpack_ts_translation_unit_decl_value_fields (data_in, bp, expr);
 
   if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
-    unpack_ts_optimization (bp, expr);
+    cl_optimization_stream_in (bp, TREE_OPTIMIZATION (expr));
 
   if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
     {
index 41dca6e6abd963965639ce5dccf2c7ce17334366..f735b5674215a1f5240f8322a3d003b2983582e9 100644 (file)
@@ -363,24 +363,6 @@ pack_ts_translation_unit_decl_value_fields (struct output_block *ob,
   bp_pack_string (ob, bp, TRANSLATION_UNIT_LANGUAGE (expr), true);
 }
 
-/* Pack a TS_OPTIMIZATION tree in EXPR to BP.  */
-
-static void
-pack_ts_optimization (struct bitpack_d *bp, tree expr)
-{
-  struct cl_optimization *t = TREE_OPTIMIZATION (expr);
-  unsigned i, len;
-
-  /* The cl_optimization is generated by the options
-     awk script, so we just recreate a byte-by-byte copy here. */
-
-  len = sizeof (struct cl_optimization);
-  for (i = 0; i < len; i++)
-    bp_pack_value (bp, ((unsigned char *)t)[i], 8);
-  /* Catch struct size mismatches between reader and writer. */
-  bp_pack_value (bp, 0x12345678, 32);
-}
-
 
 /* Pack all the non-pointer fields of the TS_OMP_CLAUSE structure
    of expression EXPR into bitpack BP.  */
@@ -473,7 +455,7 @@ streamer_pack_tree_bitfields (struct output_block *ob,
     pack_ts_translation_unit_decl_value_fields (ob, bp, expr);
 
   if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
-    pack_ts_optimization (bp, expr);
+    cl_optimization_stream_out (bp, TREE_OPTIMIZATION (expr));
 
   if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
     bp_pack_var_len_unsigned (bp, vec_safe_length (BINFO_BASE_ACCESSES (expr)));