* 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
+2011-03-24 Diego Novillo <dnovillo@google.com>
+
+ * 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 <rguenther@suse.de>
PR tree-optimization/46562
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. */
{
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;
}
{
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);
}
}
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;
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;
{
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;
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);
}
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);
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;
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)
/* 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);
}
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);
}
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);
}
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);
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
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);
}
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:
/* 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)
{
/* 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)
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 */
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 */