Hi, this patch makes us to use enum and variable length i/o at places it fits. Only non-standard thing is stremaing of built_in_class that does not allow adding LAST field or we get warning that the type no longer fits in the bitfield.
Bootstrapped/regtested x86_64-linux, OK? Honza * lto-streamer-out.c (pack_ts_fixed_cst_value_fields, pack_ts_decl_common_value_fields, pack_ts_decl_with_vis_value_fields, pack_ts_function_decl_value_fields, lto_output_builtin_tree, output_cfg, output_gimple_stmt): Use enum and variable length i/o. * lto-streamer-in.c (input_cfg, input_gimple_stmt, unpack_ts_fixed_cst_value_fields, unpack_ts_decl_common_value_fields, unpack_ts_decl_with_vis_value_fields, unpack_ts_type_common_value_fields, unpack_ts_block_value_fields, lto_get_builtin_tree): Use enum and variable length i/o. * basic-block.h (profile_status_d): Add PROFILE_LAST. * lto-streamer.h (bp_pack_int_in_range, bp_unpack_int_in_range): New functions. (bp_pack_enum, bp_unpack_enum): New macros. Index: lto-streamer-out.c =================================================================== *** lto-streamer-out.c (revision 174377) --- lto-streamer-out.c (working copy) *************** static void *** 372,380 **** pack_ts_fixed_cst_value_fields (struct bitpack_d *bp, tree expr) { struct fixed_value fv = TREE_FIXED_CST (expr); ! bp_pack_value (bp, fv.data.low, HOST_BITS_PER_WIDE_INT); ! bp_pack_value (bp, fv.data.high, HOST_BITS_PER_WIDE_INT); ! bp_pack_value (bp, fv.mode, HOST_BITS_PER_INT); } --- 372,380 ---- pack_ts_fixed_cst_value_fields (struct bitpack_d *bp, tree expr) { struct fixed_value fv = TREE_FIXED_CST (expr); ! bp_pack_enum (bp, machine_mode, MAX_MACHINE_MODE, fv.mode); ! bp_pack_var_len_int (bp, fv.data.low); ! bp_pack_var_len_int (bp, fv.data.high); } *************** pack_ts_fixed_cst_value_fields (struct b *** 384,390 **** static void pack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr) { ! bp_pack_value (bp, DECL_MODE (expr), 8); bp_pack_value (bp, DECL_NONLOCAL (expr), 1); bp_pack_value (bp, DECL_VIRTUAL_P (expr), 1); bp_pack_value (bp, DECL_IGNORED_P (expr), 1); --- 384,390 ---- static void pack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr) { ! bp_pack_enum (bp, machine_mode, MAX_MACHINE_MODE, DECL_MODE (expr)); bp_pack_value (bp, DECL_NONLOCAL (expr), 1); bp_pack_value (bp, DECL_VIRTUAL_P (expr), 1); bp_pack_value (bp, DECL_IGNORED_P (expr), 1); *************** pack_ts_decl_common_value_fields (struct *** 395,401 **** bp_pack_value (bp, DECL_DEBUG_EXPR_IS_FROM (expr), 1); bp_pack_value (bp, DECL_EXTERNAL (expr), 1); bp_pack_value (bp, DECL_GIMPLE_REG_P (expr), 1); ! bp_pack_value (bp, DECL_ALIGN (expr), HOST_BITS_PER_INT); if (TREE_CODE (expr) == LABEL_DECL) { --- 395,401 ---- bp_pack_value (bp, DECL_DEBUG_EXPR_IS_FROM (expr), 1); bp_pack_value (bp, DECL_EXTERNAL (expr), 1); bp_pack_value (bp, DECL_GIMPLE_REG_P (expr), 1); ! bp_pack_var_len_unsigned (bp, DECL_ALIGN (expr)); if (TREE_CODE (expr) == LABEL_DECL) { *************** pack_ts_decl_common_value_fields (struct *** 403,409 **** always assume an initial value of -1 so that the label_to_block_map is recreated by gimple_set_bb. */ bp_pack_value (bp, DECL_ERROR_ISSUED (expr), 1); ! bp_pack_value (bp, EH_LANDING_PAD_NR (expr), HOST_BITS_PER_INT); } if (TREE_CODE (expr) == FIELD_DECL) --- 403,409 ---- always assume an initial value of -1 so that the label_to_block_map is recreated by gimple_set_bb. */ bp_pack_value (bp, DECL_ERROR_ISSUED (expr), 1); ! bp_pack_var_len_unsigned (bp, EH_LANDING_PAD_NR (expr)); } if (TREE_CODE (expr) == FIELD_DECL) *************** pack_ts_decl_with_vis_value_fields (stru *** 460,466 **** } if (VAR_OR_FUNCTION_DECL_P (expr)) ! bp_pack_value (bp, DECL_INIT_PRIORITY (expr), HOST_BITS_PER_SHORT); } --- 460,466 ---- } if (VAR_OR_FUNCTION_DECL_P (expr)) ! bp_pack_var_len_unsigned (bp, DECL_INIT_PRIORITY (expr)); } *************** pack_ts_function_decl_value_fields (stru *** 474,481 **** should never be handled here. */ gcc_assert (!lto_stream_as_builtin_p (expr)); ! bp_pack_value (bp, DECL_FUNCTION_CODE (expr), 11); ! bp_pack_value (bp, DECL_BUILT_IN_CLASS (expr), 2); bp_pack_value (bp, DECL_STATIC_CONSTRUCTOR (expr), 1); bp_pack_value (bp, DECL_STATIC_DESTRUCTOR (expr), 1); bp_pack_value (bp, DECL_UNINLINABLE (expr), 1); --- 474,481 ---- should never be handled here. */ gcc_assert (!lto_stream_as_builtin_p (expr)); ! bp_pack_enum (bp, built_in_class, BUILT_IN_NORMAL + 1, ! DECL_BUILT_IN_CLASS (expr)); bp_pack_value (bp, DECL_STATIC_CONSTRUCTOR (expr), 1); bp_pack_value (bp, DECL_STATIC_DESTRUCTOR (expr), 1); bp_pack_value (bp, DECL_UNINLINABLE (expr), 1); *************** pack_ts_function_decl_value_fields (stru *** 492,499 **** bp_pack_value (bp, DECL_DISREGARD_INLINE_LIMITS (expr), 1); bp_pack_value (bp, DECL_PURE_P (expr), 1); bp_pack_value (bp, DECL_LOOPING_CONST_OR_PURE_P (expr), 1); if (DECL_STATIC_DESTRUCTOR (expr)) ! bp_pack_value (bp, DECL_FINI_PRIORITY (expr), HOST_BITS_PER_SHORT); } --- 492,501 ---- bp_pack_value (bp, DECL_DISREGARD_INLINE_LIMITS (expr), 1); bp_pack_value (bp, DECL_PURE_P (expr), 1); bp_pack_value (bp, DECL_LOOPING_CONST_OR_PURE_P (expr), 1); + if (DECL_BUILT_IN_CLASS (expr) != NOT_BUILT_IN) + bp_pack_value (bp, DECL_FUNCTION_CODE (expr), 11); if (DECL_STATIC_DESTRUCTOR (expr)) ! bp_pack_var_len_unsigned (bp, DECL_FINI_PRIORITY (expr)); } *************** pack_ts_function_decl_value_fields (stru *** 503,510 **** static void pack_ts_type_common_value_fields (struct bitpack_d *bp, tree expr) { ! bp_pack_value (bp, TYPE_PRECISION (expr), 10); ! bp_pack_value (bp, TYPE_MODE (expr), 8); bp_pack_value (bp, TYPE_STRING_FLAG (expr), 1); bp_pack_value (bp, TYPE_NO_FORCE_BLK (expr), 1); bp_pack_value (bp, TYPE_NEEDS_CONSTRUCTING (expr), 1); --- 505,511 ---- static void pack_ts_type_common_value_fields (struct bitpack_d *bp, tree expr) { ! bp_pack_enum (bp, machine_mode, MAX_MACHINE_MODE, TYPE_MODE (expr)); bp_pack_value (bp, TYPE_STRING_FLAG (expr), 1); bp_pack_value (bp, TYPE_NO_FORCE_BLK (expr), 1); bp_pack_value (bp, TYPE_NEEDS_CONSTRUCTING (expr), 1); *************** pack_ts_type_common_value_fields (struct *** 515,520 **** --- 516,522 ---- bp_pack_value (bp, TYPE_CONTAINS_PLACEHOLDER_INTERNAL (expr), 2); bp_pack_value (bp, TYPE_USER_ALIGN (expr), 1); bp_pack_value (bp, TYPE_READONLY (expr), 1); + bp_pack_var_len_unsigned (bp, TYPE_PRECISION (expr)); bp_pack_var_len_unsigned (bp, TYPE_ALIGN (expr)); bp_pack_var_len_int (bp, TYPE_ALIAS_SET (expr) == 0 ? 0 : -1); } *************** static void *** 527,533 **** pack_ts_block_value_fields (struct bitpack_d *bp, tree expr) { bp_pack_value (bp, BLOCK_ABSTRACT (expr), 1); ! bp_pack_value (bp, BLOCK_NUMBER (expr), 31); } /* Pack all the non-pointer fields of the TS_TRANSLATION_UNIT_DECL structure --- 529,535 ---- pack_ts_block_value_fields (struct bitpack_d *bp, tree expr) { bp_pack_value (bp, BLOCK_ABSTRACT (expr), 1); ! /* BLOCK_NUMBER is recomputed. */ } /* Pack all the non-pointer fields of the TS_TRANSLATION_UNIT_DECL structure *************** lto_output_builtin_tree (struct output_b *** 1339,1345 **** "functions on this target"); output_record_start (ob, LTO_builtin_decl); ! output_uleb128 (ob, DECL_BUILT_IN_CLASS (expr)); output_uleb128 (ob, DECL_FUNCTION_CODE (expr)); if (DECL_ASSEMBLER_NAME_SET_P (expr)) --- 1341,1348 ---- "functions on this target"); output_record_start (ob, LTO_builtin_decl); ! lto_output_enum (ob->main_stream, built_in_class, BUILT_IN_NORMAL + 1, ! DECL_BUILT_IN_CLASS (expr)); output_uleb128 (ob, DECL_FUNCTION_CODE (expr)); if (DECL_ASSEMBLER_NAME_SET_P (expr)) *************** output_cfg (struct output_block *ob, str *** 1660,1666 **** ob->main_stream = ob->cfg_stream; ! output_uleb128 (ob, profile_status_for_function (fn)); /* Output the number of the highest basic block. */ output_uleb128 (ob, last_basic_block_for_function (fn)); --- 1663,1670 ---- ob->main_stream = ob->cfg_stream; ! lto_output_enum (ob->main_stream, profile_status_d, PROFILE_LAST, ! profile_status_for_function (fn)); /* Output the number of the highest basic block. */ output_uleb128 (ob, last_basic_block_for_function (fn)); *************** output_gimple_stmt (struct output_block *** 1734,1745 **** /* Emit the tuple header. */ bp = bitpack_create (ob->main_stream); ! bp_pack_value (&bp, gimple_num_ops (stmt), sizeof (unsigned) * 8); bp_pack_value (&bp, gimple_no_warning_p (stmt), 1); if (is_gimple_assign (stmt)) bp_pack_value (&bp, gimple_assign_nontemporal_move_p (stmt), 1); bp_pack_value (&bp, gimple_has_volatile_ops (stmt), 1); ! bp_pack_value (&bp, stmt->gsbase.subcode, 16); lto_output_bitpack (&bp); /* Emit location information for the statement. */ --- 1738,1749 ---- /* Emit the tuple header. */ bp = bitpack_create (ob->main_stream); ! bp_pack_var_len_unsigned (&bp, gimple_num_ops (stmt)); bp_pack_value (&bp, gimple_no_warning_p (stmt), 1); if (is_gimple_assign (stmt)) bp_pack_value (&bp, gimple_assign_nontemporal_move_p (stmt), 1); bp_pack_value (&bp, gimple_has_volatile_ops (stmt), 1); ! bp_pack_var_len_unsigned (&bp, stmt->gsbase.subcode); lto_output_bitpack (&bp); /* Emit location information for the statement. */ *************** output_gimple_stmt (struct output_block *** 1808,1814 **** if (is_gimple_call (stmt)) { if (gimple_call_internal_p (stmt)) ! output_sleb128 (ob, (int) gimple_call_internal_fn (stmt)); else lto_output_tree_ref (ob, gimple_call_fntype (stmt)); } --- 1812,1819 ---- if (is_gimple_call (stmt)) { if (gimple_call_internal_p (stmt)) ! lto_output_enum (ob->main_stream, internal_fn, ! IFN_LAST, gimple_call_internal_fn (stmt)); else lto_output_tree_ref (ob, gimple_call_fntype (stmt)); } Index: lto-streamer-in.c =================================================================== *** lto-streamer-in.c (revision 174377) --- lto-streamer-in.c (working copy) *************** input_cfg (struct lto_input_block *ib, s *** 798,805 **** init_empty_tree_cfg_for_function (fn); init_ssa_operands (); ! profile_status_for_function (fn) = ! (enum profile_status_d) lto_input_uleb128 (ib); bb_count = lto_input_uleb128 (ib); --- 798,804 ---- init_empty_tree_cfg_for_function (fn); init_ssa_operands (); ! profile_status_for_function (fn) = lto_input_enum (ib, profile_status_d, PROFILE_LAST); bb_count = lto_input_uleb128 (ib); *************** input_gimple_stmt (struct lto_input_bloc *** 960,972 **** /* Read the tuple header. */ bp = lto_input_bitpack (ib); ! num_ops = bp_unpack_value (&bp, sizeof (unsigned) * 8); stmt = gimple_alloc (code, num_ops); stmt->gsbase.no_warning = bp_unpack_value (&bp, 1); if (is_gimple_assign (stmt)) stmt->gsbase.nontemporal_move = bp_unpack_value (&bp, 1); stmt->gsbase.has_volatile_ops = bp_unpack_value (&bp, 1); ! stmt->gsbase.subcode = bp_unpack_value (&bp, 16); /* Read location information. */ gimple_set_location (stmt, lto_input_location (ib, data_in)); --- 959,971 ---- /* Read the tuple header. */ bp = lto_input_bitpack (ib); ! num_ops = bp_unpack_var_len_unsigned (&bp); stmt = gimple_alloc (code, num_ops); stmt->gsbase.no_warning = bp_unpack_value (&bp, 1); if (is_gimple_assign (stmt)) stmt->gsbase.nontemporal_move = bp_unpack_value (&bp, 1); stmt->gsbase.has_volatile_ops = bp_unpack_value (&bp, 1); ! stmt->gsbase.subcode = bp_unpack_var_len_unsigned (&bp); /* Read location information. */ gimple_set_location (stmt, lto_input_location (ib, data_in)); *************** input_gimple_stmt (struct lto_input_bloc *** 1090,1096 **** { if (gimple_call_internal_p (stmt)) gimple_call_set_internal_fn ! (stmt, (enum internal_fn) lto_input_sleb128 (ib)); else gimple_call_set_fntype (stmt, lto_input_tree (ib, data_in)); } --- 1089,1095 ---- { if (gimple_call_internal_p (stmt)) gimple_call_set_internal_fn ! (stmt, lto_input_enum (ib, internal_fn, IFN_LAST)); else gimple_call_set_fntype (stmt, lto_input_tree (ib, data_in)); } *************** unpack_ts_fixed_cst_value_fields (struct *** 1638,1646 **** { struct fixed_value fv; ! fv.data.low = (HOST_WIDE_INT) bp_unpack_value (bp, HOST_BITS_PER_WIDE_INT); ! fv.data.high = (HOST_WIDE_INT) bp_unpack_value (bp, HOST_BITS_PER_WIDE_INT); ! fv.mode = (enum machine_mode) bp_unpack_value (bp, HOST_BITS_PER_INT); TREE_FIXED_CST (expr) = fv; } --- 1637,1645 ---- { struct fixed_value fv; ! fv.mode = bp_unpack_enum (bp, machine_mode, MAX_MACHINE_MODE); ! fv.data.low = bp_unpack_var_len_int (bp); ! fv.data.high = bp_unpack_var_len_int (bp); TREE_FIXED_CST (expr) = fv; } *************** unpack_ts_fixed_cst_value_fields (struct *** 1651,1657 **** static void unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr) { ! DECL_MODE (expr) = (enum machine_mode) bp_unpack_value (bp, 8); DECL_NONLOCAL (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_VIRTUAL_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_IGNORED_P (expr) = (unsigned) bp_unpack_value (bp, 1); --- 1650,1656 ---- static void unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr) { ! DECL_MODE (expr) = bp_unpack_enum (bp, machine_mode, MAX_MACHINE_MODE); DECL_NONLOCAL (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_VIRTUAL_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_IGNORED_P (expr) = (unsigned) bp_unpack_value (bp, 1); *************** unpack_ts_decl_common_value_fields (stru *** 1662,1673 **** DECL_DEBUG_EXPR_IS_FROM (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_EXTERNAL (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_GIMPLE_REG_P (expr) = (unsigned) bp_unpack_value (bp, 1); ! DECL_ALIGN (expr) = (unsigned) bp_unpack_value (bp, HOST_BITS_PER_INT); if (TREE_CODE (expr) == LABEL_DECL) { DECL_ERROR_ISSUED (expr) = (unsigned) bp_unpack_value (bp, 1); ! EH_LANDING_PAD_NR (expr) = (int) bp_unpack_value (bp, HOST_BITS_PER_INT); /* Always assume an initial value of -1 for LABEL_DECL_UID to force gimple_set_bb to recreate label_to_block_map. */ --- 1661,1672 ---- DECL_DEBUG_EXPR_IS_FROM (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_EXTERNAL (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_GIMPLE_REG_P (expr) = (unsigned) bp_unpack_value (bp, 1); ! DECL_ALIGN (expr) = (unsigned) bp_unpack_var_len_unsigned (bp); if (TREE_CODE (expr) == LABEL_DECL) { DECL_ERROR_ISSUED (expr) = (unsigned) bp_unpack_value (bp, 1); ! EH_LANDING_PAD_NR (expr) = (int) bp_unpack_var_len_unsigned (bp); /* Always assume an initial value of -1 for LABEL_DECL_UID to force gimple_set_bb to recreate label_to_block_map. */ *************** unpack_ts_decl_with_vis_value_fields (st *** 1730,1736 **** if (VAR_OR_FUNCTION_DECL_P (expr)) { priority_type p; ! p = (priority_type) bp_unpack_value (bp, HOST_BITS_PER_SHORT); SET_DECL_INIT_PRIORITY (expr, p); } } --- 1729,1735 ---- if (VAR_OR_FUNCTION_DECL_P (expr)) { priority_type p; ! p = (priority_type) bp_unpack_var_len_unsigned (bp); SET_DECL_INIT_PRIORITY (expr, p); } } *************** unpack_ts_decl_with_vis_value_fields (st *** 1742,1749 **** static void unpack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr) { ! DECL_FUNCTION_CODE (expr) = (enum built_in_function) bp_unpack_value (bp, 11); ! DECL_BUILT_IN_CLASS (expr) = (enum built_in_class) bp_unpack_value (bp, 2); DECL_STATIC_CONSTRUCTOR (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_STATIC_DESTRUCTOR (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_UNINLINABLE (expr) = (unsigned) bp_unpack_value (bp, 1); --- 1741,1748 ---- static void unpack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr) { ! DECL_BUILT_IN_CLASS (expr) = bp_unpack_enum (bp, built_in_class, ! BUILT_IN_NORMAL + 1); DECL_STATIC_CONSTRUCTOR (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_STATIC_DESTRUCTOR (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_UNINLINABLE (expr) = (unsigned) bp_unpack_value (bp, 1); *************** unpack_ts_function_decl_value_fields (st *** 1761,1770 **** DECL_DISREGARD_INLINE_LIMITS (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_LOOPING_CONST_OR_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1); if (DECL_STATIC_DESTRUCTOR (expr)) { ! priority_type p = (priority_type) bp_unpack_value (bp, HOST_BITS_PER_SHORT); ! SET_DECL_FINI_PRIORITY (expr, p); } } --- 1760,1783 ---- DECL_DISREGARD_INLINE_LIMITS (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_LOOPING_CONST_OR_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1); + if (DECL_BUILT_IN_CLASS (expr) != NOT_BUILT_IN) + { + DECL_FUNCTION_CODE (expr) = (enum built_in_function) bp_unpack_value (bp, 11); + if (DECL_BUILT_IN_CLASS (expr) == BUILT_IN_NORMAL + && DECL_FUNCTION_CODE (expr) >= END_BUILTINS) + fatal_error ("machine independent builtin code out of range"); + else if (DECL_BUILT_IN_CLASS (expr) == BUILT_IN_MD) + { + tree result = targetm.builtin_decl (DECL_FUNCTION_CODE (expr), true); + if (!result || result == error_mark_node) + fatal_error ("target specific builtin not available"); + } + } if (DECL_STATIC_DESTRUCTOR (expr)) { ! priority_type p; ! p = (priority_type) bp_unpack_var_len_unsigned (bp); ! SET_DECL_FINI_PRIORITY (expr, p); } } *************** unpack_ts_type_common_value_fields (stru *** 1777,1784 **** { enum machine_mode mode; ! TYPE_PRECISION (expr) = (unsigned) bp_unpack_value (bp, 10); ! mode = (enum machine_mode) bp_unpack_value (bp, 8); SET_TYPE_MODE (expr, mode); TYPE_STRING_FLAG (expr) = (unsigned) bp_unpack_value (bp, 1); TYPE_NO_FORCE_BLK (expr) = (unsigned) bp_unpack_value (bp, 1); --- 1790,1796 ---- { enum machine_mode mode; ! mode = bp_unpack_enum (bp, machine_mode, MAX_MACHINE_MODE); SET_TYPE_MODE (expr, mode); TYPE_STRING_FLAG (expr) = (unsigned) bp_unpack_value (bp, 1); TYPE_NO_FORCE_BLK (expr) = (unsigned) bp_unpack_value (bp, 1); *************** unpack_ts_type_common_value_fields (stru *** 1791,1796 **** --- 1803,1809 ---- = (unsigned) bp_unpack_value (bp, 2); TYPE_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1); TYPE_READONLY (expr) = (unsigned) bp_unpack_value (bp, 1); + TYPE_PRECISION (expr) = bp_unpack_var_len_unsigned (bp); TYPE_ALIGN (expr) = bp_unpack_var_len_unsigned (bp); TYPE_ALIAS_SET (expr) = bp_unpack_var_len_int (bp); } *************** static void *** 1803,1809 **** unpack_ts_block_value_fields (struct bitpack_d *bp, tree expr) { BLOCK_ABSTRACT (expr) = (unsigned) bp_unpack_value (bp, 1); ! BLOCK_NUMBER (expr) = (unsigned) bp_unpack_value (bp, 31); } /* Unpack all the non-pointer fields of the TS_TRANSLATION_UNIT_DECL --- 1816,1822 ---- unpack_ts_block_value_fields (struct bitpack_d *bp, tree expr) { BLOCK_ABSTRACT (expr) = (unsigned) bp_unpack_value (bp, 1); ! /* BLOCK_NUMBER is recomputed. */ } /* Unpack all the non-pointer fields of the TS_TRANSLATION_UNIT_DECL *************** lto_get_builtin_tree (struct lto_input_b *** 2603,2616 **** const char *asmname; tree result; ! fclass = (enum built_in_class) lto_input_uleb128 (ib); gcc_assert (fclass == BUILT_IN_NORMAL || fclass == BUILT_IN_MD); fcode = (enum built_in_function) lto_input_uleb128 (ib); if (fclass == BUILT_IN_NORMAL) { ! gcc_assert (fcode < END_BUILTINS); result = built_in_decls[fcode]; gcc_assert (result); } --- 2616,2630 ---- const char *asmname; tree result; ! fclass = lto_input_enum (ib, built_in_class, BUILT_IN_NORMAL + 1); gcc_assert (fclass == BUILT_IN_NORMAL || fclass == BUILT_IN_MD); fcode = (enum built_in_function) lto_input_uleb128 (ib); if (fclass == BUILT_IN_NORMAL) { ! if (fcode >= END_BUILTINS) ! fatal_error ("machine independent builtin code out of range"); result = built_in_decls[fcode]; gcc_assert (result); } Index: basic-block.h =================================================================== *** basic-block.h (revision 174377) --- basic-block.h (working copy) *************** enum profile_status_d *** 283,289 **** { PROFILE_ABSENT, PROFILE_GUESSED, ! PROFILE_READ }; /* A structure to group all the per-function control flow graph data. --- 283,290 ---- { PROFILE_ABSENT, PROFILE_GUESSED, ! PROFILE_READ, ! PROFILE_LAST /* Last value, used by profile streaming. */ }; /* A structure to group all the per-function control flow graph data. Index: lto-streamer.h =================================================================== *** lto-streamer.h (revision 174377) --- lto-streamer.h (working copy) *************** lto_input_int_in_range (struct lto_input *** 1262,1267 **** --- 1262,1308 ---- return val; } + + /* Output VAL into BP and verify it is in range MIN...MAX that is supposed + to be compile time constant. + Be host independent, limit range to 31bits. */ + + static inline void + bp_pack_int_in_range (struct bitpack_d *bp, + HOST_WIDE_INT min, + HOST_WIDE_INT max, + HOST_WIDE_INT val) + { + HOST_WIDE_INT range = max - min; + int nbits = floor_log2 (range) + 1; + + gcc_checking_assert (val >= min && val <= max && range > 0 + && range < 0x7fffffff); + + val -= min; + bp_pack_value (bp, val, nbits); + } + + /* Input VAL into BP and verify it is in range MIN...MAX that is supposed + to be compile time constant. PURPOSE is used for error reporting. */ + + static inline HOST_WIDE_INT + bp_unpack_int_in_range (struct bitpack_d *bp, + const char *purpose, + HOST_WIDE_INT min, + HOST_WIDE_INT max) + { + HOST_WIDE_INT range = max - min; + int nbits = floor_log2 (range) + 1; + HOST_WIDE_INT val = bp_unpack_value (bp, nbits); + + gcc_checking_assert (range > 0 && range < 0x7fffffff); + + if (val < min || val > max) + lto_value_range_error (purpose, val, min, max); + return val; + } + /* Output VAL of type "enum enum_name" into OBS. Assume range 0...ENUM_LAST - 1. */ #define lto_output_enum(obs,enum_name,enum_last,val) \ *************** lto_input_int_in_range (struct lto_input *** 1273,1276 **** --- 1314,1328 ---- (enum enum_name)lto_input_int_in_range ((ib), #enum_name, 0, \ (int)(enum_last) - 1) + /* Output VAL of type "enum enum_name" into BP. + Assume range 0...ENUM_LAST - 1. */ + #define bp_pack_enum(bp,enum_name,enum_last,val) \ + bp_pack_int_in_range ((bp), 0, (int)(enum_last) - 1, (int)(val)) + + /* Input enum of type "enum enum_name" from BP. + Assume range 0...ENUM_LAST - 1. */ + #define bp_unpack_enum(bp,enum_name,enum_last) \ + (enum enum_name)bp_unpack_int_in_range ((bp), #enum_name, 0, \ + (int)(enum_last) - 1) + #endif /* GCC_LTO_STREAMER_H */