Mercurial > hg > CbC > CbC_gcc
comparison gcc/genconfig.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* Generate from machine description: | 1 /* Generate from machine description: |
2 - some #define configuration flags. | 2 - some #define configuration flags. |
3 Copyright (C) 1987, 1991, 1997, 1998, 1999, 2000, 2003, 2004, 2007, 2010 | 3 Copyright (C) 1987-2017 Free Software Foundation, Inc. |
4 Free Software Foundation, Inc. | |
5 | 4 |
6 This file is part of GCC. | 5 This file is part of GCC. |
7 | 6 |
8 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
9 the terms of the GNU General Public License as published by the Free | 8 the terms of the GNU General Public License as published by the Free |
35 static int max_clobbers_per_insn; | 34 static int max_clobbers_per_insn; |
36 static int have_cc0_flag; | 35 static int have_cc0_flag; |
37 static int have_cmove_flag; | 36 static int have_cmove_flag; |
38 static int have_cond_exec_flag; | 37 static int have_cond_exec_flag; |
39 static int have_lo_sum_flag; | 38 static int have_lo_sum_flag; |
39 static int have_rotate_flag; | |
40 static int have_rotatert_flag; | |
40 static int have_peephole_flag; | 41 static int have_peephole_flag; |
41 static int have_peephole2_flag; | 42 static int have_peephole2_flag; |
42 | 43 |
43 /* Maximum number of insns seen in a split. */ | 44 /* Maximum number of insns seen in a split. */ |
44 static int max_insns_per_split = 1; | 45 static int max_insns_per_split = 1; |
48 | 49 |
49 static int clobbers_seen_this_insn; | 50 static int clobbers_seen_this_insn; |
50 static int dup_operands_seen_this_insn; | 51 static int dup_operands_seen_this_insn; |
51 | 52 |
52 static void walk_insn_part (rtx, int, int); | 53 static void walk_insn_part (rtx, int, int); |
53 static void gen_insn (rtx); | |
54 static void gen_expand (rtx); | |
55 static void gen_split (rtx); | |
56 static void gen_peephole (rtx); | |
57 static void gen_peephole2 (rtx); | |
58 | 54 |
59 /* RECOG_P will be nonzero if this pattern was seen in a context where it will | 55 /* RECOG_P will be nonzero if this pattern was seen in a context where it will |
60 be used to recognize, rather than just generate an insn. | 56 be used to recognize, rather than just generate an insn. |
61 | 57 |
62 NON_PC_SET_SRC will be nonzero if this pattern was seen in a SET_SRC | 58 NON_PC_SET_SRC will be nonzero if this pattern was seen in a SET_SRC |
85 return; | 81 return; |
86 | 82 |
87 case MATCH_OP_DUP: | 83 case MATCH_OP_DUP: |
88 case MATCH_PAR_DUP: | 84 case MATCH_PAR_DUP: |
89 ++dup_operands_seen_this_insn; | 85 ++dup_operands_seen_this_insn; |
86 /* FALLTHRU */ | |
90 case MATCH_SCRATCH: | 87 case MATCH_SCRATCH: |
91 case MATCH_PARALLEL: | 88 case MATCH_PARALLEL: |
92 case MATCH_OPERATOR: | 89 case MATCH_OPERATOR: |
93 if (XINT (part, 0) > max_recog_operands) | 90 if (XINT (part, 0) > max_recog_operands) |
94 max_recog_operands = XINT (part, 0); | 91 max_recog_operands = XINT (part, 0); |
116 case LO_SUM: | 113 case LO_SUM: |
117 if (recog_p) | 114 if (recog_p) |
118 have_lo_sum_flag = 1; | 115 have_lo_sum_flag = 1; |
119 return; | 116 return; |
120 | 117 |
118 case ROTATE: | |
119 if (recog_p) | |
120 have_rotate_flag = 1; | |
121 return; | |
122 | |
123 case ROTATERT: | |
124 if (recog_p) | |
125 have_rotatert_flag = 1; | |
126 return; | |
127 | |
121 case SET: | 128 case SET: |
122 walk_insn_part (SET_DEST (part), 0, recog_p); | 129 walk_insn_part (SET_DEST (part), 0, recog_p); |
123 walk_insn_part (SET_SRC (part), recog_p, | 130 walk_insn_part (SET_SRC (part), recog_p, |
124 GET_CODE (SET_DEST (part)) != PC); | 131 GET_CODE (SET_DEST (part)) != PC); |
125 return; | 132 return; |
166 break; | 173 break; |
167 } | 174 } |
168 } | 175 } |
169 | 176 |
170 static void | 177 static void |
171 gen_insn (rtx insn) | 178 gen_insn (md_rtx_info *info) |
172 { | 179 { |
173 int i; | 180 int i; |
174 | 181 |
175 /* Walk the insn pattern to gather the #define's status. */ | 182 /* Walk the insn pattern to gather the #define's status. */ |
183 rtx insn = info->def; | |
176 clobbers_seen_this_insn = 0; | 184 clobbers_seen_this_insn = 0; |
177 dup_operands_seen_this_insn = 0; | 185 dup_operands_seen_this_insn = 0; |
178 if (XVEC (insn, 1) != 0) | 186 if (XVEC (insn, 1) != 0) |
179 for (i = 0; i < XVECLEN (insn, 1); i++) | 187 for (i = 0; i < XVECLEN (insn, 1); i++) |
180 walk_insn_part (XVECEXP (insn, 1, i), 1, 0); | 188 walk_insn_part (XVECEXP (insn, 1, i), 1, 0); |
186 } | 194 } |
187 | 195 |
188 /* Similar but scan a define_expand. */ | 196 /* Similar but scan a define_expand. */ |
189 | 197 |
190 static void | 198 static void |
191 gen_expand (rtx insn) | 199 gen_expand (md_rtx_info *info) |
192 { | 200 { |
193 int i; | 201 int i; |
194 | 202 |
195 /* Walk the insn pattern to gather the #define's status. */ | 203 /* Walk the insn pattern to gather the #define's status. */ |
196 | 204 |
197 /* Note that we don't bother recording the number of MATCH_DUPs | 205 /* Note that we don't bother recording the number of MATCH_DUPs |
198 that occur in a gen_expand, because only reload cares about that. */ | 206 that occur in a gen_expand, because only reload cares about that. */ |
207 rtx insn = info->def; | |
199 if (XVEC (insn, 1) != 0) | 208 if (XVEC (insn, 1) != 0) |
200 for (i = 0; i < XVECLEN (insn, 1); i++) | 209 for (i = 0; i < XVECLEN (insn, 1); i++) |
201 { | 210 { |
202 /* Compute the maximum SETs and CLOBBERS | 211 /* Compute the maximum SETs and CLOBBERS |
203 in any one of the sub-insns; | 212 in any one of the sub-insns; |
212 } | 221 } |
213 | 222 |
214 /* Similar but scan a define_split. */ | 223 /* Similar but scan a define_split. */ |
215 | 224 |
216 static void | 225 static void |
217 gen_split (rtx split) | 226 gen_split (md_rtx_info *info) |
218 { | 227 { |
219 int i; | 228 int i; |
220 | 229 |
221 /* Look through the patterns that are matched | 230 /* Look through the patterns that are matched |
222 to compute the maximum operand number. */ | 231 to compute the maximum operand number. */ |
232 rtx split = info->def; | |
223 for (i = 0; i < XVECLEN (split, 0); i++) | 233 for (i = 0; i < XVECLEN (split, 0); i++) |
224 walk_insn_part (XVECEXP (split, 0, i), 1, 0); | 234 walk_insn_part (XVECEXP (split, 0, i), 1, 0); |
225 /* Look at the number of insns this insn could split into. */ | 235 /* Look at the number of insns this insn could split into. */ |
226 if (XVECLEN (split, 2) > max_insns_per_split) | 236 if (XVECLEN (split, 2) > max_insns_per_split) |
227 max_insns_per_split = XVECLEN (split, 2); | 237 max_insns_per_split = XVECLEN (split, 2); |
228 } | 238 } |
229 | 239 |
230 static void | 240 static void |
231 gen_peephole (rtx peep) | 241 gen_peephole (md_rtx_info *info) |
232 { | 242 { |
233 int i; | 243 int i; |
234 | 244 |
235 /* Look through the patterns that are matched | 245 /* Look through the patterns that are matched |
236 to compute the maximum operand number. */ | 246 to compute the maximum operand number. */ |
247 rtx peep = info->def; | |
237 for (i = 0; i < XVECLEN (peep, 0); i++) | 248 for (i = 0; i < XVECLEN (peep, 0); i++) |
238 walk_insn_part (XVECEXP (peep, 0, i), 1, 0); | 249 walk_insn_part (XVECEXP (peep, 0, i), 1, 0); |
239 } | 250 } |
240 | 251 |
241 static void | 252 static void |
242 gen_peephole2 (rtx peep) | 253 gen_peephole2 (md_rtx_info *info) |
243 { | 254 { |
244 int i, n; | 255 int i, n; |
245 | 256 |
246 /* Look through the patterns that are matched | 257 /* Look through the patterns that are matched |
247 to compute the maximum operand number. */ | 258 to compute the maximum operand number. */ |
259 rtx peep = info->def; | |
248 for (i = XVECLEN (peep, 0) - 1; i >= 0; --i) | 260 for (i = XVECLEN (peep, 0) - 1; i >= 0; --i) |
249 walk_insn_part (XVECEXP (peep, 0, i), 1, 0); | 261 walk_insn_part (XVECEXP (peep, 0, i), 1, 0); |
250 | 262 |
251 /* Look at the number of insns this insn can be matched from. */ | 263 /* Look at the number of insns this insn can be matched from. */ |
252 for (i = XVECLEN (peep, 0) - 1, n = 0; i >= 0; --i) | 264 for (i = XVECLEN (peep, 0) - 1, n = 0; i >= 0; --i) |
256 if (n > max_insns_per_peep2) | 268 if (n > max_insns_per_peep2) |
257 max_insns_per_peep2 = n; | 269 max_insns_per_peep2 = n; |
258 } | 270 } |
259 | 271 |
260 int | 272 int |
261 main (int argc, char **argv) | 273 main (int argc, const char **argv) |
262 { | 274 { |
263 rtx desc; | |
264 | |
265 progname = "genconfig"; | 275 progname = "genconfig"; |
266 | 276 |
267 if (!init_rtx_reader_args (argc, argv)) | 277 if (!init_rtx_reader_args (argc, argv)) |
268 return (FATAL_EXIT_CODE); | 278 return (FATAL_EXIT_CODE); |
269 | 279 |
278 max_recog_operands = 29; /* We will add 1 later. */ | 288 max_recog_operands = 29; /* We will add 1 later. */ |
279 max_dup_operands = 1; | 289 max_dup_operands = 1; |
280 | 290 |
281 /* Read the machine description. */ | 291 /* Read the machine description. */ |
282 | 292 |
283 while (1) | 293 md_rtx_info info; |
284 { | 294 while (read_md_rtx (&info)) |
285 int line_no, insn_code_number = 0; | 295 switch (GET_CODE (info.def)) |
286 | 296 { |
287 desc = read_md_rtx (&line_no, &insn_code_number); | 297 case DEFINE_INSN: |
288 if (desc == NULL) | 298 gen_insn (&info); |
289 break; | 299 break; |
290 | 300 |
291 switch (GET_CODE (desc)) | 301 case DEFINE_EXPAND: |
292 { | 302 gen_expand (&info); |
293 case DEFINE_INSN: | 303 break; |
294 gen_insn (desc); | 304 |
295 break; | 305 case DEFINE_SPLIT: |
296 | 306 gen_split (&info); |
297 case DEFINE_EXPAND: | 307 break; |
298 gen_expand (desc); | 308 |
299 break; | 309 case DEFINE_PEEPHOLE2: |
300 | 310 have_peephole2_flag = 1; |
301 case DEFINE_SPLIT: | 311 gen_peephole2 (&info); |
302 gen_split (desc); | 312 break; |
303 break; | 313 |
304 | 314 case DEFINE_PEEPHOLE: |
305 case DEFINE_PEEPHOLE2: | 315 have_peephole_flag = 1; |
306 have_peephole2_flag = 1; | 316 gen_peephole (&info); |
307 gen_peephole2 (desc); | 317 break; |
308 break; | 318 |
309 | 319 default: |
310 case DEFINE_PEEPHOLE: | 320 break; |
311 have_peephole_flag = 1; | 321 } |
312 gen_peephole (desc); | |
313 break; | |
314 | |
315 default: | |
316 break; | |
317 } | |
318 } | |
319 | 322 |
320 printf ("#define MAX_RECOG_OPERANDS %d\n", max_recog_operands + 1); | 323 printf ("#define MAX_RECOG_OPERANDS %d\n", max_recog_operands + 1); |
321 printf ("#define MAX_DUP_OPERANDS %d\n", max_dup_operands); | 324 printf ("#define MAX_DUP_OPERANDS %d\n", max_dup_operands); |
322 | 325 |
323 /* This is conditionally defined, in case the user writes code which emits | 326 /* This is conditionally defined, in case the user writes code which emits |
333 } | 336 } |
334 else | 337 else |
335 { | 338 { |
336 /* We output CC0_P this way to make sure that X is declared | 339 /* We output CC0_P this way to make sure that X is declared |
337 somewhere. */ | 340 somewhere. */ |
341 printf ("#define HAVE_cc0 0\n"); | |
338 printf ("#define CC0_P(X) ((X) ? 0 : 0)\n"); | 342 printf ("#define CC0_P(X) ((X) ? 0 : 0)\n"); |
339 } | 343 } |
340 | 344 |
341 if (have_cmove_flag) | 345 if (have_cmove_flag) |
342 printf ("#define HAVE_conditional_move 1\n"); | 346 printf ("#define HAVE_conditional_move 1\n"); |
347 else | |
348 printf ("#define HAVE_conditional_move 0\n"); | |
343 | 349 |
344 if (have_cond_exec_flag) | 350 if (have_cond_exec_flag) |
345 printf ("#define HAVE_conditional_execution 1\n"); | 351 printf ("#define HAVE_conditional_execution 1\n"); |
352 else | |
353 printf ("#define HAVE_conditional_execution 0\n"); | |
346 | 354 |
347 if (have_lo_sum_flag) | 355 if (have_lo_sum_flag) |
348 printf ("#define HAVE_lo_sum 1\n"); | 356 printf ("#define HAVE_lo_sum 1\n"); |
357 else | |
358 printf ("#define HAVE_lo_sum 0\n"); | |
359 | |
360 if (have_rotate_flag) | |
361 printf ("#define HAVE_rotate 1\n"); | |
362 | |
363 if (have_rotatert_flag) | |
364 printf ("#define HAVE_rotatert 1\n"); | |
349 | 365 |
350 if (have_peephole_flag) | 366 if (have_peephole_flag) |
351 printf ("#define HAVE_peephole 1\n"); | 367 printf ("#define HAVE_peephole 1\n"); |
368 else | |
369 printf ("#define HAVE_peephole 0\n"); | |
352 | 370 |
353 if (have_peephole2_flag) | 371 if (have_peephole2_flag) |
354 { | 372 { |
355 printf ("#define HAVE_peephole2 1\n"); | 373 printf ("#define HAVE_peephole2 1\n"); |
356 printf ("#define MAX_INSNS_PER_PEEP2 %d\n", max_insns_per_peep2); | 374 printf ("#define MAX_INSNS_PER_PEEP2 %d\n", max_insns_per_peep2); |
357 } | 375 } |
358 | 376 else |
359 puts("\n#endif /* GCC_INSN_CONFIG_H */"); | 377 { |
378 printf ("#define HAVE_peephole2 0\n"); | |
379 printf ("#define MAX_INSNS_PER_PEEP2 0\n"); | |
380 } | |
381 | |
382 puts ("\n#endif /* GCC_INSN_CONFIG_H */"); | |
360 | 383 |
361 if (ferror (stdout) || fflush (stdout) || fclose (stdout)) | 384 if (ferror (stdout) || fflush (stdout) || fclose (stdout)) |
362 return FATAL_EXIT_CODE; | 385 return FATAL_EXIT_CODE; |
363 | 386 |
364 return SUCCESS_EXIT_CODE; | 387 return SUCCESS_EXIT_CODE; |