From a183b5c7af929e900fa073b48f72ee6436411748 Mon Sep 17 00:00:00 2001 From: Diego Novillo Date: Thu, 24 Mar 2011 08:39:59 -0400 Subject: [PATCH] lto-opts.c (input_data_block): Move to lto-streamer-in.c. * lto-opts.c (input_data_block): Move to lto-streamer-in.c. * lto-streamer-in.c (input_string_internal): Add clarifying comments. (lto_input_data_block): Move from lto-opts.c. Make extern. Update all users. (lto_input_string): Rename from input_string. Make extern. Update all users. * lto-streamer-out.c (lto_output_string_with_length): Rename from output_string_with_length. Output 0 to indicate a non-NULL string. Update all callers to not emit 0. (lto_output_string): Rename from output_string. Make extern. Update all users. (lto_output_decl_state_streams): Make extern. (lto_output_decl_state_refs): Make extern. * lto-streamer.h (lto_input_string): Declare. (lto_input_data_block): Declare. (lto_output_string): Declare. (lto_output_string_with_length): Declare. (lto_output_decl_state_streams): Declare. (lto_output_decl_state_refs): Declare. From-SVN: r171387 --- gcc/ChangeLog | 24 ++++++++++++++++ gcc/lto-opts.c | 26 +++++------------ gcc/lto-streamer-in.c | 27 ++++++++++++++---- gcc/lto-streamer-out.c | 63 +++++++++++++++++++----------------------- gcc/lto-streamer.h | 15 ++++++++++ 5 files changed, 97 insertions(+), 58 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9dec3e406fa..feace5129f0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,27 @@ +2011-03-24 Diego Novillo + + * lto-opts.c (input_data_block): Move to lto-streamer-in.c. + * lto-streamer-in.c (input_string_internal): Add clarifying + comments. + (lto_input_data_block): Move from lto-opts.c. Make extern. + Update all users. + (lto_input_string): Rename from input_string. Make extern. + Update all users. + * lto-streamer-out.c (lto_output_string_with_length): Rename from + output_string_with_length. + Output 0 to indicate a non-NULL string. Update all callers to + not emit 0. + (lto_output_string): Rename from output_string. Make extern. + Update all users. + (lto_output_decl_state_streams): Make extern. + (lto_output_decl_state_refs): Make extern. + * lto-streamer.h (lto_input_string): Declare. + (lto_input_data_block): Declare. + (lto_output_string): Declare. + (lto_output_string_with_length): Declare. + (lto_output_decl_state_streams): Declare. + (lto_output_decl_state_refs): Declare. + 2011-03-24 Richard Guenther PR tree-optimization/46562 diff --git a/gcc/lto-opts.c b/gcc/lto-opts.c index ec4e78daf39..9979e8da821 100644 --- a/gcc/lto-opts.c +++ b/gcc/lto-opts.c @@ -162,18 +162,6 @@ output_string_stream (struct lto_output_stream *stream, const char *string) output_data_stream (stream, &flag, sizeof (flag)); } -/* Read LENGTH bytes from STREAM to ADDR. */ - -static void -input_data_block (struct lto_input_block *ib, void *addr, size_t length) -{ - size_t i; - unsigned char *const buffer = (unsigned char *const) addr; - - for (i = 0; i < length; i++) - buffer[i] = lto_input_1_unsigned (ib); -} - /* Return a string from IB. The string is allocated, and the caller is responsible for freeing it. */ @@ -182,15 +170,15 @@ input_string_block (struct lto_input_block *ib) { bool flag; - input_data_block (ib, &flag, sizeof (flag)); + lto_input_data_block (ib, &flag, sizeof (flag)); if (flag) { size_t length; char *string; - input_data_block (ib, &length, sizeof (length)); + lto_input_data_block (ib, &length, sizeof (length)); string = (char *) xcalloc (1, length + 1); - input_data_block (ib, string, length); + lto_input_data_block (ib, string, length); return string; } @@ -336,16 +324,16 @@ input_options (struct lto_input_block *ib) { size_t length, i; - input_data_block (ib, &length, sizeof (length)); + lto_input_data_block (ib, &length, sizeof (length)); for (i = 0; i < length; i++) { opt_t o; - input_data_block (ib, &o.type, sizeof (o.type)); - input_data_block (ib, &o.code, sizeof (o.code)); + lto_input_data_block (ib, &o.type, sizeof (o.type)); + lto_input_data_block (ib, &o.code, sizeof (o.code)); o.arg = input_string_block (ib); - input_data_block (ib, &o.value, sizeof (o.value)); + lto_input_data_block (ib, &o.value, sizeof (o.value)); VEC_safe_push (opt_t, heap, file_options, &o); } } diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index a87325835f2..383bfc23060 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -140,7 +140,10 @@ input_string_internal (struct data_in *data_in, struct lto_input_block *ib, unsigned int loc; const char *result; + /* Read the location of the string from IB. */ loc = lto_input_uleb128 (ib); + + /* Get the string stored at location LOC in DATA_IN->STRINGS. */ LTO_INIT_INPUT_BLOCK (str_tab, data_in->strings, loc, data_in->strings_len); len = lto_input_uleb128 (&str_tab); *rlen = len; @@ -191,10 +194,24 @@ input_identifier (struct data_in *data_in, struct lto_input_block *ib) return get_identifier_with_length (ptr, len); } + +/* Read LENGTH bytes from STREAM to ADDR. */ + +void +lto_input_data_block (struct lto_input_block *ib, void *addr, size_t length) +{ + size_t i; + unsigned char *const buffer = (unsigned char *const) addr; + + for (i = 0; i < length; i++) + buffer[i] = lto_input_1_unsigned (ib); +} + + /* Read a NULL terminated string from the string table in DATA_IN. */ -static const char * -input_string (struct data_in *data_in, struct lto_input_block *ib) +const char * +lto_input_string (struct data_in *data_in, struct lto_input_block *ib) { unsigned int len; const char *ptr; @@ -275,7 +292,7 @@ lto_input_location (struct lto_input_block *ib, struct data_in *data_in) { expanded_location xloc; - xloc.file = input_string (data_in, ib); + xloc.file = lto_input_string (data_in, ib); if (xloc.file == NULL) return UNKNOWN_LOCATION; @@ -2307,7 +2324,7 @@ lto_input_ts_translation_unit_decl_tree_pointers (struct lto_input_block *ib, struct data_in *data_in, tree expr) { - TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (input_string (data_in, ib)); + TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (lto_input_string (data_in, ib)); VEC_safe_push (tree, gc, all_translation_units, expr); } @@ -2590,7 +2607,7 @@ lto_get_builtin_tree (struct lto_input_block *ib, struct data_in *data_in) else gcc_unreachable (); - asmname = input_string (data_in, ib); + asmname = lto_input_string (data_in, ib); if (asmname) set_builtin_user_assembler_name (result, asmname); diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index ba916b64c34..48579478b4d 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -154,11 +154,11 @@ destroy_output_block (struct output_block *ob) table in OB. The string might or might not include a trailing '\0'. Then put the index onto the INDEX_STREAM. */ -static void -output_string_with_length (struct output_block *ob, - struct lto_output_stream *index_stream, - const char *s, - unsigned int len) +void +lto_output_string_with_length (struct output_block *ob, + struct lto_output_stream *index_stream, + const char *s, + unsigned int len) { struct string_slot **slot; struct string_slot s_slot; @@ -170,6 +170,9 @@ output_string_with_length (struct output_block *ob, s_slot.len = len; s_slot.slot_num = 0; + /* Indicate that this is not a NULL string. */ + lto_output_uleb128_stream (index_stream, 0); + slot = (struct string_slot **) htab_find_slot (ob->string_hash_table, &s_slot, INSERT); if (*slot == NULL) @@ -200,16 +203,14 @@ output_string_with_length (struct output_block *ob, /* Output the '\0' terminated STRING to the string table in OB. Then put the index onto the INDEX_STREAM. */ -static void -output_string (struct output_block *ob, - struct lto_output_stream *index_stream, - const char *string) +void +lto_output_string (struct output_block *ob, + struct lto_output_stream *index_stream, + const char *string) { if (string) - { - lto_output_uleb128_stream (index_stream, 0); - output_string_with_length (ob, index_stream, string, strlen (string) + 1); - } + lto_output_string_with_length (ob, index_stream, string, + strlen (string) + 1); else lto_output_uleb128_stream (index_stream, 1); } @@ -224,12 +225,9 @@ output_string_cst (struct output_block *ob, tree string) { if (string) - { - lto_output_uleb128_stream (index_stream, 0); - output_string_with_length (ob, index_stream, - TREE_STRING_POINTER (string), - TREE_STRING_LENGTH (string)); - } + lto_output_string_with_length (ob, index_stream, + TREE_STRING_POINTER (string), + TREE_STRING_LENGTH (string )); else lto_output_uleb128_stream (index_stream, 1); } @@ -244,12 +242,9 @@ output_identifier (struct output_block *ob, tree id) { if (id) - { - lto_output_uleb128_stream (index_stream, 0); - output_string_with_length (ob, index_stream, - IDENTIFIER_POINTER (id), - IDENTIFIER_LENGTH (id)); - } + lto_output_string_with_length (ob, index_stream, + IDENTIFIER_POINTER (id), + IDENTIFIER_LENGTH (id)); else lto_output_uleb128_stream (index_stream, 1); } @@ -611,13 +606,13 @@ lto_output_location (struct output_block *ob, location_t loc) if (loc == UNKNOWN_LOCATION) { - output_string (ob, ob->main_stream, NULL); + lto_output_string (ob, ob->main_stream, NULL); return; } xloc = expand_location (loc); - output_string (ob, ob->main_stream, xloc.file); + lto_output_string (ob, ob->main_stream, xloc.file); output_sleb128 (ob, xloc.line); output_sleb128 (ob, xloc.column); output_sleb128 (ob, xloc.sysp); @@ -1155,7 +1150,7 @@ static void lto_output_ts_translation_unit_decl_tree_pointers (struct output_block *ob, tree expr) { - output_string (ob, ob->main_stream, TRANSLATION_UNIT_LANGUAGE (expr)); + lto_output_string (ob, ob->main_stream, TRANSLATION_UNIT_LANGUAGE (expr)); } /* Helper for lto_output_tree. Write all pointer fields in EXPR to output @@ -1320,12 +1315,12 @@ lto_output_builtin_tree (struct output_block *ob, tree expr, int ix) reader side from adding a second '*', we omit it here. */ const char *str = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (expr)); if (strlen (str) > 1 && str[0] == '*') - output_string (ob, ob->main_stream, &str[1]); + lto_output_string (ob, ob->main_stream, &str[1]); else - output_string (ob, ob->main_stream, NULL); + lto_output_string (ob, ob->main_stream, NULL); } else - output_string (ob, ob->main_stream, NULL); + lto_output_string (ob, ob->main_stream, NULL); } @@ -1745,7 +1740,7 @@ output_gimple_stmt (struct output_block *ob, gimple stmt) lto_output_uleb128_stream (ob->main_stream, gimple_asm_noutputs (stmt)); lto_output_uleb128_stream (ob->main_stream, gimple_asm_nclobbers (stmt)); lto_output_uleb128_stream (ob->main_stream, gimple_asm_nlabels (stmt)); - output_string (ob, ob->main_stream, gimple_asm_string (stmt)); + lto_output_string (ob, ob->main_stream, gimple_asm_string (stmt)); /* Fallthru */ case GIMPLE_ASSIGN: @@ -2342,7 +2337,7 @@ write_global_references (struct output_block *ob, /* Write all the streams in an lto_out_decl_state STATE using output block OB and output stream OUT_STREAM. */ -static void +void lto_output_decl_state_streams (struct output_block *ob, struct lto_out_decl_state *state) { @@ -2356,7 +2351,7 @@ lto_output_decl_state_streams (struct output_block *ob, /* Write all the references in an lto_out_decl_state STATE using output block OB and output stream OUT_STREAM. */ -static void +void lto_output_decl_state_refs (struct output_block *ob, struct lto_output_stream *out_stream, struct lto_out_decl_state *state) diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index d8669a21529..c7c865dfa5c 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -862,6 +862,9 @@ extern struct data_in *lto_data_in_create (struct lto_file_decl_data *, const char *, unsigned, VEC(ld_plugin_symbol_resolution_t,heap) *); extern void lto_data_in_delete (struct data_in *); +extern const char *lto_input_string (struct data_in *, + struct lto_input_block *); +extern void lto_input_data_block (struct lto_input_block *, void *, size_t); /* In lto-streamer-out.c */ @@ -870,6 +873,18 @@ extern struct output_block *create_output_block (enum lto_section_type); extern void destroy_output_block (struct output_block *); extern void lto_output_tree (struct output_block *, tree, bool); extern void produce_asm (struct output_block *ob, tree fn); +extern void lto_output_string (struct output_block *, + struct lto_output_stream *, + const char *); +extern void lto_output_string_with_length (struct output_block *, + struct lto_output_stream *, + const char *, + unsigned int); +void lto_output_decl_state_streams (struct output_block *, + struct lto_out_decl_state *); +void lto_output_decl_state_refs (struct output_block *, + struct lto_output_stream *, + struct lto_out_decl_state *); /* In lto-cgraph.c */ -- 2.30.2