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