comparison gcc/data-streamer-in.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Routines for restoring various data types from a file stream. This deals 1 /* Routines for restoring various data types from a file stream. This deals
2 with various data types like strings, integers, enums, etc. 2 with various data types like strings, integers, enums, etc.
3 3
4 Copyright (C) 2011-2018 Free Software Foundation, Inc. 4 Copyright (C) 2011-2020 Free Software Foundation, Inc.
5 Contributed by Diego Novillo <dnovillo@google.com> 5 Contributed by Diego Novillo <dnovillo@google.com>
6 6
7 This file is part of GCC. 7 This file is part of GCC.
8 8
9 GCC is free software; you can redistribute it and/or modify it under 9 GCC is free software; you can redistribute it and/or modify it under
31 31
32 /* Read a string from the string table in DATA_IN using input block 32 /* Read a string from the string table in DATA_IN using input block
33 IB. Write the length to RLEN. */ 33 IB. Write the length to RLEN. */
34 34
35 static const char * 35 static const char *
36 string_for_index (struct data_in *data_in, unsigned int loc, unsigned int *rlen) 36 string_for_index (class data_in *data_in, unsigned int loc, unsigned int *rlen)
37 { 37 {
38 unsigned int len; 38 unsigned int len;
39 const char *result; 39 const char *result;
40 40
41 if (!loc) 41 if (!loc)
60 60
61 /* Read a string from the string table in DATA_IN using input block 61 /* Read a string from the string table in DATA_IN using input block
62 IB. Write the length to RLEN. */ 62 IB. Write the length to RLEN. */
63 63
64 const char * 64 const char *
65 streamer_read_indexed_string (struct data_in *data_in, 65 streamer_read_indexed_string (class data_in *data_in,
66 struct lto_input_block *ib, unsigned int *rlen) 66 class lto_input_block *ib, unsigned int *rlen)
67 { 67 {
68 return string_for_index (data_in, streamer_read_uhwi (ib), rlen); 68 return string_for_index (data_in, streamer_read_uhwi (ib), rlen);
69 } 69 }
70 70
71 71
72 /* Read a NULL terminated string from the string table in DATA_IN. */ 72 /* Read a NULL terminated string from the string table in DATA_IN. */
73 73
74 const char * 74 const char *
75 streamer_read_string (struct data_in *data_in, struct lto_input_block *ib) 75 streamer_read_string (class data_in *data_in, class lto_input_block *ib)
76 { 76 {
77 unsigned int len; 77 unsigned int len;
78 const char *ptr; 78 const char *ptr;
79 79
80 ptr = streamer_read_indexed_string (data_in, ib, &len); 80 ptr = streamer_read_indexed_string (data_in, ib, &len);
89 89
90 /* Read a string from the string table in DATA_IN using the bitpack BP. 90 /* Read a string from the string table in DATA_IN using the bitpack BP.
91 Write the length to RLEN. */ 91 Write the length to RLEN. */
92 92
93 const char * 93 const char *
94 bp_unpack_indexed_string (struct data_in *data_in, 94 bp_unpack_indexed_string (class data_in *data_in,
95 struct bitpack_d *bp, unsigned int *rlen) 95 struct bitpack_d *bp, unsigned int *rlen)
96 { 96 {
97 return string_for_index (data_in, bp_unpack_var_len_unsigned (bp), rlen); 97 return string_for_index (data_in, bp_unpack_var_len_unsigned (bp), rlen);
98 } 98 }
99 99
100 100
101 /* Read a NULL terminated string from the string table in DATA_IN. */ 101 /* Read a NULL terminated string from the string table in DATA_IN. */
102 102
103 const char * 103 const char *
104 bp_unpack_string (struct data_in *data_in, struct bitpack_d *bp) 104 bp_unpack_string (class data_in *data_in, struct bitpack_d *bp)
105 { 105 {
106 unsigned int len; 106 unsigned int len;
107 const char *ptr; 107 const char *ptr;
108 108
109 ptr = bp_unpack_indexed_string (data_in, bp, &len); 109 ptr = bp_unpack_indexed_string (data_in, bp, &len);
117 117
118 118
119 /* Read an unsigned HOST_WIDE_INT number from IB. */ 119 /* Read an unsigned HOST_WIDE_INT number from IB. */
120 120
121 unsigned HOST_WIDE_INT 121 unsigned HOST_WIDE_INT
122 streamer_read_uhwi (struct lto_input_block *ib) 122 streamer_read_uhwi (class lto_input_block *ib)
123 { 123 {
124 unsigned HOST_WIDE_INT result; 124 unsigned HOST_WIDE_INT result;
125 int shift; 125 int shift;
126 unsigned HOST_WIDE_INT byte; 126 unsigned HOST_WIDE_INT byte;
127 unsigned int p = ib->p; 127 unsigned int p = ib->p;
152 152
153 153
154 /* Read a HOST_WIDE_INT number from IB. */ 154 /* Read a HOST_WIDE_INT number from IB. */
155 155
156 HOST_WIDE_INT 156 HOST_WIDE_INT
157 streamer_read_hwi (struct lto_input_block *ib) 157 streamer_read_hwi (class lto_input_block *ib)
158 { 158 {
159 HOST_WIDE_INT result = 0; 159 HOST_WIDE_INT result = 0;
160 int shift = 0; 160 int shift = 0;
161 unsigned HOST_WIDE_INT byte; 161 unsigned HOST_WIDE_INT byte;
162 162
173 return result; 173 return result;
174 } 174 }
175 } 175 }
176 } 176 }
177 177
178 /* Read a poly_uint64 from IB. */
179
180 poly_uint64
181 streamer_read_poly_uint64 (class lto_input_block *ib)
182 {
183 poly_uint64 res;
184 for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
185 res.coeffs[i] = streamer_read_uhwi (ib);
186 return res;
187 }
188
178 /* Read gcov_type value from IB. */ 189 /* Read gcov_type value from IB. */
179 190
180 gcov_type 191 gcov_type
181 streamer_read_gcov_count (struct lto_input_block *ib) 192 streamer_read_gcov_count (class lto_input_block *ib)
182 { 193 {
183 gcov_type ret = streamer_read_hwi (ib); 194 gcov_type ret = streamer_read_hwi (ib);
184 return ret; 195 return ret;
185 } 196 }
186 197
187 /* Read the physical representation of a wide_int val from 198 /* Read the physical representation of a wide_int val from
188 input block IB. */ 199 input block IB. */
189 200
190 wide_int 201 wide_int
191 streamer_read_wide_int (struct lto_input_block *ib) 202 streamer_read_wide_int (class lto_input_block *ib)
192 { 203 {
193 HOST_WIDE_INT a[WIDE_INT_MAX_ELTS]; 204 HOST_WIDE_INT a[WIDE_INT_MAX_ELTS];
194 int i; 205 int i;
195 int prec = streamer_read_uhwi (ib); 206 int prec = streamer_read_uhwi (ib);
196 int len = streamer_read_uhwi (ib); 207 int len = streamer_read_uhwi (ib);
201 212
202 /* Read the physical representation of a widest_int val from 213 /* Read the physical representation of a widest_int val from
203 input block IB. */ 214 input block IB. */
204 215
205 widest_int 216 widest_int
206 streamer_read_widest_int (struct lto_input_block *ib) 217 streamer_read_widest_int (class lto_input_block *ib)
207 { 218 {
208 HOST_WIDE_INT a[WIDE_INT_MAX_ELTS]; 219 HOST_WIDE_INT a[WIDE_INT_MAX_ELTS];
209 int i; 220 int i;
210 int prec ATTRIBUTE_UNUSED = streamer_read_uhwi (ib); 221 int prec ATTRIBUTE_UNUSED = streamer_read_uhwi (ib);
211 int len = streamer_read_uhwi (ib); 222 int len = streamer_read_uhwi (ib);