aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/lto-streamer-out.c2
-rw-r--r--gcc/lto-streamer.h4
-rw-r--r--gcc/optc-save-gen.awk57
-rw-r--r--gcc/opth-gen.awk3
-rw-r--r--gcc/tree-streamer-in.c17
-rw-r--r--gcc/tree-streamer-out.c20
7 files changed, 78 insertions, 36 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 42fe8fa..bb82d0e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index f376a30..ab06727 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -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));
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
index 8e5ee62..000c147 100644
--- a/gcc/lto-streamer.h
+++ b/gcc/lto-streamer.h
@@ -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);
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 8616834..54c2ed2 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -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 "}";
}
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index a8a04b7..56e706a 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -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 */"
diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c
index c63bc60..a11a46e 100644
--- a/gcc/tree-streamer-in.c
+++ b/gcc/tree-streamer-in.c
@@ -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))
{
diff --git a/gcc/tree-streamer-out.c b/gcc/tree-streamer-out.c
index 41dca6e..f735b56 100644
--- a/gcc/tree-streamer-out.c
+++ b/gcc/tree-streamer-out.c
@@ -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)));