From a12c248769d216b201337f5898ea6e12c3e58f38 Mon Sep 17 00:00:00 2001 From: hubicka Date: Fri, 27 May 2011 09:57:40 +0000 Subject: * lto-streamer-out.c (lto_string_index): break out from...; offset by 1 so 0 means NULL string. (lto_output_string_with_length): ... here. (lto_output_string, output_string_cst, output_identifier): Update handling of NULL strings. (lto_output_location_bitpack): New function. (lto_output_location): Use it. (lto_output_tree_ref): Use output_record_start. (pack_ts_type_common_value_fields): Pack aliagn & alias set in var len values. * lto-streamer-in.c (string_for_index): Break out from ...; offset values by 1. (input_string_internal): ... here; (input_string_cst, input_identifier, lto_input_string): Update handling of NULL strings. (lto_input_location_bitpack): New function (lto_input_location): Use it. (unpack_ts_type_common_value_fields): Pack align & alias in var len values. * lto-streamer.h (bp_pack_val_len_unsigned, bp_pack_val_len_int, bp_unpack_val_len_unsigned, bp_unpack_val_len_int): Declare. (bp_pack_value): Sanity check the value range. * lto-section-in.c (bp_unpack_val_len_unsigned, bp_unpack_val_len_int): New functions. * lto-section-out.h (bp_pack_val_len_unsigned, bp_pack_val_len_int): New functions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174325 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/lto-section-in.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'gcc/lto-section-in.c') diff --git a/gcc/lto-section-in.c b/gcc/lto-section-in.c index b6277a35532..0c2c4c0f1c0 100644 --- a/gcc/lto-section-in.c +++ b/gcc/lto-section-in.c @@ -127,6 +127,51 @@ lto_input_sleb128 (struct lto_input_block *ib) } +/* Unpack VAL from BP in a variant of uleb format. */ + +unsigned HOST_WIDE_INT +bp_unpack_var_len_unsigned (struct bitpack_d *bp) +{ + unsigned HOST_WIDE_INT result = 0; + int shift = 0; + unsigned HOST_WIDE_INT half_byte; + + while (true) + { + half_byte = bp_unpack_value (bp, 4); + result |= (half_byte & 0x7) << shift; + shift += 3; + if ((half_byte & 0x8) == 0) + return result; + } +} + + +/* Unpack VAL from BP in a variant of sleb format. */ + +HOST_WIDE_INT +bp_unpack_var_len_int (struct bitpack_d *bp) +{ + HOST_WIDE_INT result = 0; + int shift = 0; + unsigned HOST_WIDE_INT half_byte; + + while (true) + { + half_byte = bp_unpack_value (bp, 4); + result |= (half_byte & 0x7) << shift; + shift += 3; + if ((half_byte & 0x8) == 0) + { + if ((shift < HOST_BITS_PER_WIDE_INT) && (half_byte & 0x4)) + result |= - ((HOST_WIDE_INT)1 << shift); + + return result; + } + } +} + + /* Hooks so that the ipa passes can call into the lto front end to get sections. */ -- cgit v1.2.1