diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-29 11:40:25 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-29 11:40:25 +0000 |
commit | 34c4d8ed1d740eabb18a7d755bd302a4f5448aaa (patch) | |
tree | eed156dd5808f73e4b6f5b4bfe6c145931ecbe0b /gcc/lto-streamer.h | |
parent | 3aa8e69ea6e1949c0a2328c1149e3a96a1c3baff (diff) | |
download | gcc-34c4d8ed1d740eabb18a7d755bd302a4f5448aaa.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174394 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/lto-streamer.h')
-rw-r--r-- | gcc/lto-streamer.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index 4508818a4a6..150442d8d8d 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -1262,6 +1262,47 @@ lto_input_int_in_range (struct lto_input_block *ib, 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) \ @@ -1273,4 +1314,15 @@ lto_input_int_in_range (struct lto_input_block *ib, (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 */ |