* 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
+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.
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));
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);
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 "}";
}
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 */"
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. */
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))
{
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. */
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)));