annotate gcc/data-streamer.h @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Generic streaming support for various data types.
kono
parents:
diff changeset
2
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
3 Copyright (C) 2011-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
4 Contributed by Diego Novillo <dnovillo@google.com>
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 This file is part of GCC.
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
9 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
10 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
11 version.
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
16 for more details.
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
19 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
20 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 #ifndef GCC_DATA_STREAMER_H
kono
parents:
diff changeset
23 #define GCC_DATA_STREAMER_H
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 #include "lto-streamer.h"
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 /* Data structures used to pack values and bitflags into a vector of
kono
parents:
diff changeset
28 words. Used to stream values of a fixed number of bits in a space
kono
parents:
diff changeset
29 efficient way. */
kono
parents:
diff changeset
30 static unsigned const BITS_PER_BITPACK_WORD = HOST_BITS_PER_WIDE_INT;
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 typedef unsigned HOST_WIDE_INT bitpack_word_t;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 struct bitpack_d
kono
parents:
diff changeset
35 {
kono
parents:
diff changeset
36 /* The position of the first unused or unconsumed bit in the word. */
kono
parents:
diff changeset
37 unsigned pos;
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 /* The current word we are (un)packing. */
kono
parents:
diff changeset
40 bitpack_word_t word;
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 /* The lto_output_stream or the lto_input_block we are streaming to/from. */
kono
parents:
diff changeset
43 void *stream;
kono
parents:
diff changeset
44 };
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 /* In data-streamer.c */
kono
parents:
diff changeset
47 void bp_pack_var_len_unsigned (struct bitpack_d *, unsigned HOST_WIDE_INT);
kono
parents:
diff changeset
48 void bp_pack_var_len_int (struct bitpack_d *, HOST_WIDE_INT);
kono
parents:
diff changeset
49 unsigned HOST_WIDE_INT bp_unpack_var_len_unsigned (struct bitpack_d *);
kono
parents:
diff changeset
50 HOST_WIDE_INT bp_unpack_var_len_int (struct bitpack_d *);
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 /* In data-streamer-out.c */
kono
parents:
diff changeset
53 void streamer_write_zero (struct output_block *);
kono
parents:
diff changeset
54 void streamer_write_uhwi (struct output_block *, unsigned HOST_WIDE_INT);
kono
parents:
diff changeset
55 void streamer_write_hwi (struct output_block *, HOST_WIDE_INT);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
56 void streamer_write_poly_uint64 (struct output_block *, poly_uint64);
111
kono
parents:
diff changeset
57 void streamer_write_gcov_count (struct output_block *, gcov_type);
kono
parents:
diff changeset
58 void streamer_write_string (struct output_block *, struct lto_output_stream *,
kono
parents:
diff changeset
59 const char *, bool);
kono
parents:
diff changeset
60 void streamer_write_string_with_length (struct output_block *,
kono
parents:
diff changeset
61 struct lto_output_stream *,
kono
parents:
diff changeset
62 const char *, unsigned int, bool);
kono
parents:
diff changeset
63 void bp_pack_string_with_length (struct output_block *, struct bitpack_d *,
kono
parents:
diff changeset
64 const char *, unsigned int, bool);
kono
parents:
diff changeset
65 void bp_pack_string (struct output_block *, struct bitpack_d *,
kono
parents:
diff changeset
66 const char *, bool);
kono
parents:
diff changeset
67 void streamer_write_uhwi_stream (struct lto_output_stream *,
kono
parents:
diff changeset
68 unsigned HOST_WIDE_INT);
kono
parents:
diff changeset
69 void streamer_write_hwi_stream (struct lto_output_stream *, HOST_WIDE_INT);
kono
parents:
diff changeset
70 void streamer_write_gcov_count_stream (struct lto_output_stream *, gcov_type);
kono
parents:
diff changeset
71 void streamer_write_data_stream (struct lto_output_stream *, const void *,
kono
parents:
diff changeset
72 size_t);
kono
parents:
diff changeset
73 void streamer_write_wide_int (struct output_block *, const wide_int &);
kono
parents:
diff changeset
74 void streamer_write_widest_int (struct output_block *, const widest_int &);
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 /* In data-streamer-in.c */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
77 const char *streamer_read_string (class data_in *, class lto_input_block *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
78 const char *streamer_read_indexed_string (class data_in *,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
79 class lto_input_block *,
111
kono
parents:
diff changeset
80 unsigned int *);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
81 const char *bp_unpack_indexed_string (class data_in *, struct bitpack_d *,
111
kono
parents:
diff changeset
82 unsigned int *);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
83 const char *bp_unpack_string (class data_in *, struct bitpack_d *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
84 unsigned HOST_WIDE_INT streamer_read_uhwi (class lto_input_block *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
85 HOST_WIDE_INT streamer_read_hwi (class lto_input_block *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
86 poly_uint64 streamer_read_poly_uint64 (class lto_input_block *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
87 gcov_type streamer_read_gcov_count (class lto_input_block *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
88 wide_int streamer_read_wide_int (class lto_input_block *);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
89 widest_int streamer_read_widest_int (class lto_input_block *);
111
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 /* Returns a new bit-packing context for bit-packing into S. */
kono
parents:
diff changeset
92 static inline struct bitpack_d
kono
parents:
diff changeset
93 bitpack_create (struct lto_output_stream *s)
kono
parents:
diff changeset
94 {
kono
parents:
diff changeset
95 struct bitpack_d bp;
kono
parents:
diff changeset
96 bp.pos = 0;
kono
parents:
diff changeset
97 bp.word = 0;
kono
parents:
diff changeset
98 bp.stream = (void *)s;
kono
parents:
diff changeset
99 return bp;
kono
parents:
diff changeset
100 }
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 /* Pack the NBITS bit sized value VAL into the bit-packing context BP. */
kono
parents:
diff changeset
103 static inline void
kono
parents:
diff changeset
104 bp_pack_value (struct bitpack_d *bp, bitpack_word_t val, unsigned nbits)
kono
parents:
diff changeset
105 {
kono
parents:
diff changeset
106 bitpack_word_t word = bp->word;
kono
parents:
diff changeset
107 int pos = bp->pos;
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 /* Verify that VAL fits in the NBITS. */
kono
parents:
diff changeset
110 gcc_checking_assert (nbits == BITS_PER_BITPACK_WORD
kono
parents:
diff changeset
111 || !(val & ~(((bitpack_word_t)1<<nbits)-1)));
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 /* If val does not fit into the current bitpack word switch to the
kono
parents:
diff changeset
114 next one. */
kono
parents:
diff changeset
115 if (pos + nbits > BITS_PER_BITPACK_WORD)
kono
parents:
diff changeset
116 {
kono
parents:
diff changeset
117 streamer_write_uhwi_stream ((struct lto_output_stream *) bp->stream,
kono
parents:
diff changeset
118 word);
kono
parents:
diff changeset
119 word = val;
kono
parents:
diff changeset
120 pos = nbits;
kono
parents:
diff changeset
121 }
kono
parents:
diff changeset
122 else
kono
parents:
diff changeset
123 {
kono
parents:
diff changeset
124 word |= val << pos;
kono
parents:
diff changeset
125 pos += nbits;
kono
parents:
diff changeset
126 }
kono
parents:
diff changeset
127 bp->word = word;
kono
parents:
diff changeset
128 bp->pos = pos;
kono
parents:
diff changeset
129 }
kono
parents:
diff changeset
130
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
131 /* Pack VAL into the bit-packing context BP, using NBITS for each
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
132 coefficient. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
133 static inline void
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
134 bp_pack_poly_value (struct bitpack_d *bp,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
135 const poly_int<NUM_POLY_INT_COEFFS, bitpack_word_t> &val,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
136 unsigned nbits)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
137 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
138 for (int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
139 bp_pack_value (bp, val.coeffs[i], nbits);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
140 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
141
111
kono
parents:
diff changeset
142 /* Finishes bit-packing of BP. */
kono
parents:
diff changeset
143 static inline void
kono
parents:
diff changeset
144 streamer_write_bitpack (struct bitpack_d *bp)
kono
parents:
diff changeset
145 {
kono
parents:
diff changeset
146 streamer_write_uhwi_stream ((struct lto_output_stream *) bp->stream,
kono
parents:
diff changeset
147 bp->word);
kono
parents:
diff changeset
148 bp->word = 0;
kono
parents:
diff changeset
149 bp->pos = 0;
kono
parents:
diff changeset
150 }
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 /* Returns a new bit-packing context for bit-unpacking from IB. */
kono
parents:
diff changeset
153 static inline struct bitpack_d
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
154 streamer_read_bitpack (class lto_input_block *ib)
111
kono
parents:
diff changeset
155 {
kono
parents:
diff changeset
156 struct bitpack_d bp;
kono
parents:
diff changeset
157 bp.word = streamer_read_uhwi (ib);
kono
parents:
diff changeset
158 bp.pos = 0;
kono
parents:
diff changeset
159 bp.stream = (void *)ib;
kono
parents:
diff changeset
160 return bp;
kono
parents:
diff changeset
161 }
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 /* Unpacks NBITS bits from the bit-packing context BP and returns them. */
kono
parents:
diff changeset
164 static inline bitpack_word_t
kono
parents:
diff changeset
165 bp_unpack_value (struct bitpack_d *bp, unsigned nbits)
kono
parents:
diff changeset
166 {
kono
parents:
diff changeset
167 bitpack_word_t mask, val;
kono
parents:
diff changeset
168 int pos = bp->pos;
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 mask = (nbits == BITS_PER_BITPACK_WORD
kono
parents:
diff changeset
171 ? (bitpack_word_t) -1
kono
parents:
diff changeset
172 : ((bitpack_word_t) 1 << nbits) - 1);
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 /* If there are not continuous nbits in the current bitpack word
kono
parents:
diff changeset
175 switch to the next one. */
kono
parents:
diff changeset
176 if (pos + nbits > BITS_PER_BITPACK_WORD)
kono
parents:
diff changeset
177 {
kono
parents:
diff changeset
178 bp->word = val
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
179 = streamer_read_uhwi ((class lto_input_block *)bp->stream);
111
kono
parents:
diff changeset
180 bp->pos = nbits;
kono
parents:
diff changeset
181 return val & mask;
kono
parents:
diff changeset
182 }
kono
parents:
diff changeset
183 val = bp->word;
kono
parents:
diff changeset
184 val >>= pos;
kono
parents:
diff changeset
185 bp->pos = pos + nbits;
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 return val & mask;
kono
parents:
diff changeset
188 }
kono
parents:
diff changeset
189
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
190 /* Unpacks a polynomial value from the bit-packing context BP in which each
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
191 coefficient has NBITS bits. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
192 static inline poly_int<NUM_POLY_INT_COEFFS, bitpack_word_t>
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
193 bp_unpack_poly_value (struct bitpack_d *bp, unsigned nbits)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
194 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
195 poly_int_pod<NUM_POLY_INT_COEFFS, bitpack_word_t> x;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
196 for (int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
197 x.coeffs[i] = bp_unpack_value (bp, nbits);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
198 return x;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
199 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
200
111
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 /* Write a character to the output block. */
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 static inline void
kono
parents:
diff changeset
205 streamer_write_char_stream (struct lto_output_stream *obs, char c)
kono
parents:
diff changeset
206 {
kono
parents:
diff changeset
207 /* No space left. */
kono
parents:
diff changeset
208 if (obs->left_in_block == 0)
kono
parents:
diff changeset
209 lto_append_block (obs);
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 /* Write the actual character. */
kono
parents:
diff changeset
212 char *current_pointer = obs->current_pointer;
kono
parents:
diff changeset
213 *(current_pointer++) = c;
kono
parents:
diff changeset
214 obs->current_pointer = current_pointer;
kono
parents:
diff changeset
215 obs->total_size++;
kono
parents:
diff changeset
216 obs->left_in_block--;
kono
parents:
diff changeset
217 }
kono
parents:
diff changeset
218
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 /* Read byte from the input block. */
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 static inline unsigned char
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
223 streamer_read_uchar (class lto_input_block *ib)
111
kono
parents:
diff changeset
224 {
kono
parents:
diff changeset
225 if (ib->p >= ib->len)
kono
parents:
diff changeset
226 lto_section_overrun (ib);
kono
parents:
diff changeset
227 return (ib->data[ib->p++]);
kono
parents:
diff changeset
228 }
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 /* Output VAL into OBS and verify it is in range MIN...MAX that is supposed
kono
parents:
diff changeset
231 to be compile time constant.
kono
parents:
diff changeset
232 Be host independent, limit range to 31bits. */
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 static inline void
kono
parents:
diff changeset
235 streamer_write_hwi_in_range (struct lto_output_stream *obs,
kono
parents:
diff changeset
236 HOST_WIDE_INT min,
kono
parents:
diff changeset
237 HOST_WIDE_INT max,
kono
parents:
diff changeset
238 HOST_WIDE_INT val)
kono
parents:
diff changeset
239 {
kono
parents:
diff changeset
240 HOST_WIDE_INT range = max - min;
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 gcc_checking_assert (val >= min && val <= max && range > 0
kono
parents:
diff changeset
243 && range < 0x7fffffff);
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 val -= min;
kono
parents:
diff changeset
246 streamer_write_uhwi_stream (obs, (unsigned HOST_WIDE_INT) val);
kono
parents:
diff changeset
247 }
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 /* Input VAL into OBS and verify it is in range MIN...MAX that is supposed
kono
parents:
diff changeset
250 to be compile time constant. PURPOSE is used for error reporting. */
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252 static inline HOST_WIDE_INT
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
253 streamer_read_hwi_in_range (class lto_input_block *ib,
111
kono
parents:
diff changeset
254 const char *purpose,
kono
parents:
diff changeset
255 HOST_WIDE_INT min,
kono
parents:
diff changeset
256 HOST_WIDE_INT max)
kono
parents:
diff changeset
257 {
kono
parents:
diff changeset
258 HOST_WIDE_INT range = max - min;
kono
parents:
diff changeset
259 unsigned HOST_WIDE_INT uval = streamer_read_uhwi (ib);
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 gcc_checking_assert (range > 0 && range < 0x7fffffff);
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 HOST_WIDE_INT val = (HOST_WIDE_INT) (uval + (unsigned HOST_WIDE_INT) min);
kono
parents:
diff changeset
264 if (val < min || val > max)
kono
parents:
diff changeset
265 lto_value_range_error (purpose, val, min, max);
kono
parents:
diff changeset
266 return val;
kono
parents:
diff changeset
267 }
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269 /* Output VAL into BP and verify it is in range MIN...MAX that is supposed
kono
parents:
diff changeset
270 to be compile time constant.
kono
parents:
diff changeset
271 Be host independent, limit range to 31bits. */
kono
parents:
diff changeset
272
kono
parents:
diff changeset
273 static inline void
kono
parents:
diff changeset
274 bp_pack_int_in_range (struct bitpack_d *bp,
kono
parents:
diff changeset
275 HOST_WIDE_INT min,
kono
parents:
diff changeset
276 HOST_WIDE_INT max,
kono
parents:
diff changeset
277 HOST_WIDE_INT val)
kono
parents:
diff changeset
278 {
kono
parents:
diff changeset
279 HOST_WIDE_INT range = max - min;
kono
parents:
diff changeset
280 int nbits = floor_log2 (range) + 1;
kono
parents:
diff changeset
281
kono
parents:
diff changeset
282 gcc_checking_assert (val >= min && val <= max && range > 0
kono
parents:
diff changeset
283 && range < 0x7fffffff);
kono
parents:
diff changeset
284
kono
parents:
diff changeset
285 val -= min;
kono
parents:
diff changeset
286 bp_pack_value (bp, val, nbits);
kono
parents:
diff changeset
287 }
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 /* Input VAL into BP and verify it is in range MIN...MAX that is supposed
kono
parents:
diff changeset
290 to be compile time constant. PURPOSE is used for error reporting. */
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 static inline HOST_WIDE_INT
kono
parents:
diff changeset
293 bp_unpack_int_in_range (struct bitpack_d *bp,
kono
parents:
diff changeset
294 const char *purpose,
kono
parents:
diff changeset
295 HOST_WIDE_INT min,
kono
parents:
diff changeset
296 HOST_WIDE_INT max)
kono
parents:
diff changeset
297 {
kono
parents:
diff changeset
298 HOST_WIDE_INT range = max - min;
kono
parents:
diff changeset
299 int nbits = floor_log2 (range) + 1;
kono
parents:
diff changeset
300 HOST_WIDE_INT val = bp_unpack_value (bp, nbits);
kono
parents:
diff changeset
301
kono
parents:
diff changeset
302 gcc_checking_assert (range > 0 && range < 0x7fffffff);
kono
parents:
diff changeset
303
kono
parents:
diff changeset
304 if (val < min || val > max)
kono
parents:
diff changeset
305 lto_value_range_error (purpose, val, min, max);
kono
parents:
diff changeset
306 return val;
kono
parents:
diff changeset
307 }
kono
parents:
diff changeset
308
kono
parents:
diff changeset
309 /* Output VAL of type "enum enum_name" into OBS.
kono
parents:
diff changeset
310 Assume range 0...ENUM_LAST - 1. */
kono
parents:
diff changeset
311 #define streamer_write_enum(obs,enum_name,enum_last,val) \
kono
parents:
diff changeset
312 streamer_write_hwi_in_range ((obs), 0, (int)(enum_last) - 1, (int)(val))
kono
parents:
diff changeset
313
kono
parents:
diff changeset
314 /* Input enum of type "enum enum_name" from IB.
kono
parents:
diff changeset
315 Assume range 0...ENUM_LAST - 1. */
kono
parents:
diff changeset
316 #define streamer_read_enum(ib,enum_name,enum_last) \
kono
parents:
diff changeset
317 (enum enum_name)streamer_read_hwi_in_range ((ib), #enum_name, 0, \
kono
parents:
diff changeset
318 (int)(enum_last) - 1)
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 /* Output VAL of type "enum enum_name" into BP.
kono
parents:
diff changeset
321 Assume range 0...ENUM_LAST - 1. */
kono
parents:
diff changeset
322 #define bp_pack_enum(bp,enum_name,enum_last,val) \
kono
parents:
diff changeset
323 bp_pack_int_in_range ((bp), 0, (int)(enum_last) - 1, (int)(val))
kono
parents:
diff changeset
324
kono
parents:
diff changeset
325 /* Input enum of type "enum enum_name" from BP.
kono
parents:
diff changeset
326 Assume range 0...ENUM_LAST - 1. */
kono
parents:
diff changeset
327 #define bp_unpack_enum(bp,enum_name,enum_last) \
kono
parents:
diff changeset
328 (enum enum_name)bp_unpack_int_in_range ((bp), #enum_name, 0, \
kono
parents:
diff changeset
329 (int)(enum_last) - 1)
kono
parents:
diff changeset
330
kono
parents:
diff changeset
331 /* Output the start of a record with TAG to output block OB. */
kono
parents:
diff changeset
332
kono
parents:
diff changeset
333 static inline void
kono
parents:
diff changeset
334 streamer_write_record_start (struct output_block *ob, enum LTO_tags tag)
kono
parents:
diff changeset
335 {
kono
parents:
diff changeset
336 streamer_write_enum (ob->main_stream, LTO_tags, LTO_NUM_TAGS, tag);
kono
parents:
diff changeset
337 }
kono
parents:
diff changeset
338
kono
parents:
diff changeset
339 /* Return the next tag in the input block IB. */
kono
parents:
diff changeset
340
kono
parents:
diff changeset
341 static inline enum LTO_tags
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
342 streamer_read_record_start (class lto_input_block *ib)
111
kono
parents:
diff changeset
343 {
kono
parents:
diff changeset
344 return streamer_read_enum (ib, LTO_tags, LTO_NUM_TAGS);
kono
parents:
diff changeset
345 }
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347 #endif /* GCC_DATA_STREAMER_H */