aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto-streamer-out.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-02-26 13:26:11 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2015-02-26 13:26:11 +0100
commitdb847fa8f2cca6139188b8dfa0a7064319b19193 (patch)
tree4cfafb39979c3cd73421161d2411ccb6693f4928 /gcc/lto-streamer-out.c
parent948f9b763d00ae77117179edf1980eb40d284326 (diff)
downloadgcc-db847fa8f2cca6139188b8dfa0a7064319b19193.zip
gcc-db847fa8f2cca6139188b8dfa0a7064319b19193.tar.gz
gcc-db847fa8f2cca6139188b8dfa0a7064319b19193.tar.bz2
passes.c (ipa_write_summaries_1): Call lto_output_init_mode_table.
* passes.c (ipa_write_summaries_1): Call lto_output_init_mode_table. (ipa_write_optimization_summaries): Likewise. * tree-streamer.h: Include data-streamer.h. (streamer_mode_table): Declare extern variable. (bp_pack_machine_mode, bp_unpack_machine_mode): New inline functions. * lto-streamer-out.c (lto_output_init_mode_table, lto_write_mode_table): New functions. (produce_asm_for_decls): Call lto_write_mode_table when streaming offloading LTO. * lto-section-in.c (lto_section_name): Add "mode_table" entry. (lto_create_simple_input_block): Add mode_table argument to the lto_input_block constructors. * ipa-prop.c (ipa_prop_read_section, read_replacements_section): Likewise. * data-streamer-in.c (string_for_index): Likewise. * ipa-inline-analysis.c (inline_read_section): Likewise. * ipa-icf.c (sem_item_optimizer::read_section): Likewise. * lto-cgraph.c (input_cgraph_opt_section): Likewise. * lto-streamer-in.c (lto_read_body_or_constructor, lto_input_toplevel_asms): Likewise. (lto_input_mode_table): New function. * tree-streamer-out.c (pack_ts_fixed_cst_value_fields, pack_ts_decl_common_value_fields, pack_ts_type_common_value_fields): Use bp_pack_machine_mode. * real.h (struct real_format): Add name field. * lto-streamer.h (enum lto_section_type): Add LTO_section_mode_table. (class lto_input_block): Add mode_table member. (lto_input_block::lto_input_block): Add mode_table_ argument, initialize mode_table. (struct lto_file_decl_data): Add mode_table field. (lto_input_mode_table, lto_output_init_mode_table): New prototypes. * tree-streamer-in.c (unpack_ts_fixed_cst_value_fields, unpack_ts_decl_common_value_fields, unpack_ts_type_common_value_fields): Call bp_unpack_machine_mode. * tree-streamer.c (streamer_mode_table): New variable. * real.c (ieee_single_format, mips_single_format, motorola_single_format, spu_single_format, ieee_double_format, mips_double_format, motorola_double_format, ieee_extended_motorola_format, ieee_extended_intel_96_format, ieee_extended_intel_128_format, ieee_extended_intel_96_round_53_format, ibm_extended_format, mips_extended_format, ieee_quad_format, mips_quad_format, vax_f_format, vax_d_format, vax_g_format, decimal_single_format, decimal_double_format, decimal_quad_format, ieee_half_format, arm_half_format, real_internal_format): Add name field. * config/pdp11/pdp11.c (pdp11_f_format, pdp11_d_format): Likewise. lto/ * lto.c (lto_mode_identity_table): New variable. (lto_read_decls): Add mode_table argument to the lto_input_block constructor. (lto_file_finalize): Initialize mode_table. (lto_init): Initialize lto_mode_identity_table. From-SVN: r221005
Diffstat (limited to 'gcc/lto-streamer-out.c')
-rw-r--r--gcc/lto-streamer-out.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 0c27c9d..671bac3 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -2642,6 +2642,96 @@ produce_symtab (struct output_block *ob)
}
+/* Init the streamer_mode_table for output, where we collect info on what
+ machine_mode values have been streamed. */
+void
+lto_output_init_mode_table (void)
+{
+ memset (streamer_mode_table, '\0', MAX_MACHINE_MODE);
+}
+
+
+/* Write the mode table. */
+static void
+lto_write_mode_table (void)
+{
+ struct output_block *ob;
+ ob = create_output_block (LTO_section_mode_table);
+ bitpack_d bp = bitpack_create (ob->main_stream);
+
+ /* Ensure that for GET_MODE_INNER (m) != VOIDmode we have
+ also the inner mode marked. */
+ for (int i = 0; i < (int) MAX_MACHINE_MODE; i++)
+ if (streamer_mode_table[i])
+ {
+ machine_mode m = (machine_mode) i;
+ if (GET_MODE_INNER (m) != VOIDmode)
+ streamer_mode_table[(int) GET_MODE_INNER (m)] = 1;
+ }
+ /* First stream modes that have GET_MODE_INNER (m) == VOIDmode,
+ so that we can refer to them afterwards. */
+ for (int pass = 0; pass < 2; pass++)
+ for (int i = 0; i < (int) MAX_MACHINE_MODE; i++)
+ if (streamer_mode_table[i] && i != (int) VOIDmode && i != (int) BLKmode)
+ {
+ machine_mode m = (machine_mode) i;
+ if ((GET_MODE_INNER (m) == VOIDmode) ^ (pass == 0))
+ continue;
+ bp_pack_value (&bp, m, 8);
+ bp_pack_enum (&bp, mode_class, MAX_MODE_CLASS, GET_MODE_CLASS (m));
+ bp_pack_value (&bp, GET_MODE_SIZE (m), 8);
+ bp_pack_value (&bp, GET_MODE_PRECISION (m), 16);
+ bp_pack_value (&bp, GET_MODE_INNER (m), 8);
+ bp_pack_value (&bp, GET_MODE_NUNITS (m), 8);
+ switch (GET_MODE_CLASS (m))
+ {
+ case MODE_FRACT:
+ case MODE_UFRACT:
+ case MODE_ACCUM:
+ case MODE_UACCUM:
+ bp_pack_value (&bp, GET_MODE_IBIT (m), 8);
+ bp_pack_value (&bp, GET_MODE_FBIT (m), 8);
+ break;
+ case MODE_FLOAT:
+ case MODE_DECIMAL_FLOAT:
+ bp_pack_string (ob, &bp, REAL_MODE_FORMAT (m)->name, true);
+ break;
+ default:
+ break;
+ }
+ bp_pack_string (ob, &bp, GET_MODE_NAME (m), true);
+ }
+ bp_pack_value (&bp, VOIDmode, 8);
+
+ streamer_write_bitpack (&bp);
+
+ char *section_name
+ = lto_get_section_name (LTO_section_mode_table, NULL, NULL);
+ lto_begin_section (section_name, !flag_wpa);
+ free (section_name);
+
+ /* The entire header stream is computed here. */
+ struct lto_simple_header_with_strings header;
+ memset (&header, 0, sizeof (header));
+
+ /* Write the header. */
+ header.major_version = LTO_major_version;
+ header.minor_version = LTO_minor_version;
+
+ header.main_size = ob->main_stream->total_size;
+ header.string_size = ob->string_stream->total_size;
+ lto_write_data (&header, sizeof header);
+
+ /* Put all of the gimple and the string table out the asm file as a
+ block of text. */
+ lto_write_stream (ob->main_stream);
+ lto_write_stream (ob->string_stream);
+
+ lto_end_section ();
+ destroy_output_block (ob);
+}
+
+
/* This pass is run after all of the functions are serialized and all
of the IPA passes have written their serialized forms. This pass
causes the vector of all of the global decls and types used from
@@ -2749,4 +2839,6 @@ produce_asm_for_decls (void)
lto_symtab_encoder_delete (ob->decl_state->symtab_node_encoder);
lto_function_decl_states.release ();
destroy_output_block (ob);
+ if (lto_stream_offload_p)
+ lto_write_mode_table ();
}