00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 #include "hconfig.h"
00093 #include "system.h"
00094 #include "rtl.h"
00095 #include "errors.h"
00096 #include "gensupport.h"
00097
00098
00099
00100
00101
00102 #define MAX_MAX_OPERANDS 40
00103
00104 static int n_occurrences PARAMS ((int, const char *));
00105 static const char *strip_whitespace PARAMS ((const char *));
00106
00107
00108
00109
00110
00111 static int next_code_number;
00112
00113
00114
00115
00116 static int next_index_number;
00117
00118
00119
00120 static int next_operand_number = 1;
00121
00122
00123
00124 struct operand_data
00125 {
00126 struct operand_data *next;
00127 int index;
00128 const char *predicate;
00129 const char *constraint;
00130 enum machine_mode mode;
00131 unsigned char n_alternatives;
00132 char address_p;
00133 char strict_low;
00134 char eliminable;
00135 char seen;
00136 };
00137
00138
00139
00140 static struct operand_data null_operand =
00141 {
00142 0, 0, "", "", VOIDmode, 0, 0, 0, 0, 0
00143 };
00144
00145 static struct operand_data *odata = &null_operand;
00146 static struct operand_data **odata_end = &null_operand.next;
00147
00148
00149
00150 #define INSN_OUTPUT_FORMAT_NONE 0
00151 #define INSN_OUTPUT_FORMAT_SINGLE 1
00152 #define INSN_OUTPUT_FORMAT_MULTI 2
00153 #define INSN_OUTPUT_FORMAT_FUNCTION 3
00154
00155
00156
00157
00158 struct data
00159 {
00160 struct data *next;
00161 const char *name;
00162 const char *template;
00163 int code_number;
00164 int index_number;
00165 int lineno;
00166 int n_operands;
00167 int n_dups;
00168 int n_alternatives;
00169 int operand_number;
00170 int output_format;
00171 struct operand_data operand[MAX_MAX_OPERANDS];
00172 };
00173
00174
00175
00176 static struct data *idata, **idata_end = &idata;
00177
00178 static void output_prologue PARAMS ((void));
00179 static void output_predicate_decls PARAMS ((void));
00180 static void output_operand_data PARAMS ((void));
00181 static void output_insn_data PARAMS ((void));
00182 static void output_get_insn_name PARAMS ((void));
00183 static void scan_operands PARAMS ((struct data *, rtx, int, int));
00184 static int compare_operands PARAMS ((struct operand_data *,
00185 struct operand_data *));
00186 static void place_operands PARAMS ((struct data *));
00187 static void process_template PARAMS ((struct data *, const char *));
00188 static void validate_insn_alternatives PARAMS ((struct data *));
00189 static void validate_insn_operands PARAMS ((struct data *));
00190 static void gen_insn PARAMS ((rtx, int));
00191 static void gen_peephole PARAMS ((rtx, int));
00192 static void gen_expand PARAMS ((rtx, int));
00193 static void gen_split PARAMS ((rtx, int));
00194
00195 const char *
00196 get_insn_name (index)
00197 int index;
00198 {
00199 static char buf[100];
00200
00201 struct data *i, *last_named = NULL;
00202 for (i = idata; i ; i = i->next)
00203 {
00204 if (i->index_number == index)
00205 return i->name;
00206 if (i->name)
00207 last_named = i;
00208 }
00209
00210 if (last_named)
00211 sprintf(buf, "%s+%d", last_named->name, index - last_named->index_number);
00212 else
00213 sprintf(buf, "insn %d", index);
00214
00215 return buf;
00216 }
00217
00218 static void
00219 output_prologue ()
00220 {
00221 printf ("/* Generated automatically by the program `genoutput'\n\
00222 from the machine description file `md'. */\n\n");
00223
00224 printf ("#include \"config.h\"\n");
00225 printf ("#include \"system.h\"\n");
00226 printf ("#include \"flags.h\"\n");
00227 printf ("#include \"ggc.h\"\n");
00228 printf ("#include \"rtl.h\"\n");
00229 printf ("#include \"expr.h\"\n");
00230 printf ("#include \"insn-codes.h\"\n");
00231 printf ("#include \"tm_p.h\"\n");
00232 printf ("#include \"function.h\"\n");
00233 printf ("#include \"regs.h\"\n");
00234 printf ("#include \"hard-reg-set.h\"\n");
00235 printf ("#include \"real.h\"\n");
00236 printf ("#include \"insn-config.h\"\n\n");
00237 printf ("#include \"conditions.h\"\n");
00238 #ifdef SGI_MONGOOSE
00239 printf ("#include \"insn-flags.h\"\n");
00240 #endif
00241 printf ("#include \"insn-attr.h\"\n\n");
00242 printf ("#include \"recog.h\"\n\n");
00243 printf ("#include \"toplev.h\"\n");
00244 printf ("#include \"output.h\"\n");
00245 }
00246
00247
00248
00249
00250
00251 struct predicate { const char *name; struct predicate *next; };
00252
00253 static void
00254 output_predicate_decls ()
00255 {
00256 struct predicate *predicates = 0;
00257 struct operand_data *d;
00258 struct predicate *p, *next;
00259
00260 for (d = odata; d; d = d->next)
00261 if (d->predicate && d->predicate[0])
00262 {
00263 for (p = predicates; p; p = p->next)
00264 if (strcmp (p->name, d->predicate) == 0)
00265 break;
00266
00267 if (p == 0)
00268 {
00269 printf ("extern int %s PARAMS ((rtx, enum machine_mode));\n",
00270 d->predicate);
00271 p = (struct predicate *) xmalloc (sizeof (struct predicate));
00272 p->name = d->predicate;
00273 p->next = predicates;
00274 predicates = p;
00275 }
00276 }
00277
00278 printf ("\n\n");
00279 for (p = predicates; p; p = next)
00280 {
00281 next = p->next;
00282 free (p);
00283 }
00284 }
00285
00286 static void
00287 output_operand_data ()
00288 {
00289 struct operand_data *d;
00290
00291 printf ("\nstatic const struct insn_operand_data operand_data[] = \n{\n");
00292
00293 for (d = odata; d; d = d->next)
00294 {
00295 printf (" {\n");
00296
00297 printf (" %s,\n",
00298 d->predicate && d->predicate[0] ? d->predicate : "0");
00299
00300 printf (" \"%s\",\n", d->constraint ? d->constraint : "");
00301
00302 printf (" %smode,\n", GET_MODE_NAME (d->mode));
00303
00304 printf (" %d,\n", d->strict_low);
00305
00306 printf (" %d\n", d->eliminable);
00307
00308 printf(" },\n");
00309 }
00310 printf("};\n\n\n");
00311 }
00312
00313 static void
00314 output_insn_data ()
00315 {
00316 struct data *d;
00317 int name_offset = 0;
00318 int next_name_offset;
00319 const char * last_name = 0;
00320 const char * next_name = 0;
00321 struct data *n;
00322
00323 for (n = idata, next_name_offset = 1; n; n = n->next, next_name_offset++)
00324 if (n->name)
00325 {
00326 next_name = n->name;
00327 break;
00328 }
00329
00330 printf ("\nconst struct insn_data insn_data[] = \n{\n");
00331
00332 for (d = idata; d; d = d->next)
00333 {
00334 printf (" {\n");
00335
00336 if (d->name)
00337 {
00338 printf (" \"%s\",\n", d->name);
00339 name_offset = 0;
00340 last_name = d->name;
00341 next_name = 0;
00342 for (n = d->next, next_name_offset = 1; n;
00343 n = n->next, next_name_offset++)
00344 {
00345 if (n->name)
00346 {
00347 next_name = n->name;
00348 break;
00349 }
00350 }
00351 }
00352 else
00353 {
00354 name_offset++;
00355 if (next_name && (last_name == 0
00356 || name_offset > next_name_offset / 2))
00357 printf (" \"%s-%d\",\n", next_name,
00358 next_name_offset - name_offset);
00359 else
00360 printf (" \"%s+%d\",\n", last_name, name_offset);
00361 }
00362
00363 switch (d->output_format)
00364 {
00365 case INSN_OUTPUT_FORMAT_NONE:
00366 printf (" 0,\n");
00367 break;
00368 case INSN_OUTPUT_FORMAT_SINGLE:
00369 #ifndef SGI_MONGOOSE
00370 {
00371 const char *p = d->template;
00372 char prev = 0;
00373
00374 printf (" \"");
00375 while (*p)
00376 {
00377 if (IS_VSPACE (*p) && prev != '\\')
00378 {
00379
00380
00381 if (*p == '\n' && prev != '\r')
00382 printf ("\\n\\\n");
00383 }
00384 else
00385 putchar (*p);
00386 prev = *p;
00387 ++p;
00388 }
00389 printf ("\",\n");
00390 }
00391 #else
00392 printf (" \"%s\",\n", d->template);
00393 #endif
00394 break;
00395 case INSN_OUTPUT_FORMAT_MULTI:
00396 case INSN_OUTPUT_FORMAT_FUNCTION:
00397 printf (" (const PTR) output_%d,\n", d->code_number);
00398 break;
00399 default:
00400 abort ();
00401 }
00402
00403 if (d->name && d->name[0] != '*')
00404 printf (" (insn_gen_fn) gen_%s,\n", d->name);
00405 else
00406 printf (" 0,\n");
00407
00408 printf (" &operand_data[%d],\n", d->operand_number);
00409 printf (" %d,\n", d->n_operands);
00410 printf (" %d,\n", d->n_dups);
00411 printf (" %d,\n", d->n_alternatives);
00412 printf (" %d\n", d->output_format);
00413
00414 printf(" },\n");
00415 }
00416 printf ("};\n\n\n");
00417 }
00418
00419 static void
00420 output_get_insn_name ()
00421 {
00422 printf ("const char *\n");
00423 printf ("get_insn_name (code)\n");
00424 printf (" int code;\n");
00425 printf ("{\n");
00426 printf (" return insn_data[code].name;\n");
00427 printf ("}\n");
00428 }
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438 static int max_opno;
00439 static int num_dups;
00440
00441 static void
00442 scan_operands (d, part, this_address_p, this_strict_low)
00443 struct data *d;
00444 rtx part;
00445 int this_address_p;
00446 int this_strict_low;
00447 {
00448 int i, j;
00449 const char *format_ptr;
00450 int opno;
00451
00452 if (part == 0)
00453 return;
00454
00455 switch (GET_CODE (part))
00456 {
00457 case MATCH_OPERAND:
00458 opno = XINT (part, 0);
00459 if (opno > max_opno)
00460 max_opno = opno;
00461 if (max_opno >= MAX_MAX_OPERANDS)
00462 {
00463 message_with_line (d->lineno,
00464 "maximum number of operands exceeded");
00465 have_error = 1;
00466 return;
00467 }
00468 if (d->operand[opno].seen)
00469 {
00470 message_with_line (d->lineno,
00471 "repeated operand number %d\n", opno);
00472 have_error = 1;
00473 }
00474
00475 d->operand[opno].seen = 1;
00476 d->operand[opno].mode = GET_MODE (part);
00477 d->operand[opno].strict_low = this_strict_low;
00478 d->operand[opno].predicate = XSTR (part, 1);
00479 d->operand[opno].constraint = strip_whitespace (XSTR (part, 2));
00480 d->operand[opno].n_alternatives
00481 = n_occurrences (',', d->operand[opno].constraint) + 1;
00482 d->operand[opno].address_p = this_address_p;
00483 d->operand[opno].eliminable = 1;
00484 return;
00485
00486 case MATCH_SCRATCH:
00487 opno = XINT (part, 0);
00488 if (opno > max_opno)
00489 max_opno = opno;
00490 if (max_opno >= MAX_MAX_OPERANDS)
00491 {
00492 message_with_line (d->lineno,
00493 "maximum number of operands exceeded");
00494 have_error = 1;
00495 return;
00496 }
00497 if (d->operand[opno].seen)
00498 {
00499 message_with_line (d->lineno,
00500 "repeated operand number %d\n", opno);
00501 have_error = 1;
00502 }
00503
00504 d->operand[opno].seen = 1;
00505 d->operand[opno].mode = GET_MODE (part);
00506 d->operand[opno].strict_low = 0;
00507 d->operand[opno].predicate = "scratch_operand";
00508 d->operand[opno].constraint = strip_whitespace (XSTR (part, 1));
00509 d->operand[opno].n_alternatives
00510 = n_occurrences (',', d->operand[opno].constraint) + 1;
00511 d->operand[opno].address_p = 0;
00512 d->operand[opno].eliminable = 0;
00513 return;
00514
00515 case MATCH_OPERATOR:
00516 case MATCH_PARALLEL:
00517 opno = XINT (part, 0);
00518 if (opno > max_opno)
00519 max_opno = opno;
00520 if (max_opno >= MAX_MAX_OPERANDS)
00521 {
00522 message_with_line (d->lineno,
00523 "maximum number of operands exceeded");
00524 have_error = 1;
00525 return;
00526 }
00527 if (d->operand[opno].seen)
00528 {
00529 message_with_line (d->lineno,
00530 "repeated operand number %d\n", opno);
00531 have_error = 1;
00532 }
00533
00534 d->operand[opno].seen = 1;
00535 d->operand[opno].mode = GET_MODE (part);
00536 d->operand[opno].strict_low = 0;
00537 d->operand[opno].predicate = XSTR (part, 1);
00538 d->operand[opno].constraint = 0;
00539 d->operand[opno].address_p = 0;
00540 d->operand[opno].eliminable = 0;
00541 for (i = 0; i < XVECLEN (part, 2); i++)
00542 scan_operands (d, XVECEXP (part, 2, i), 0, 0);
00543 return;
00544
00545 case MATCH_DUP:
00546 case MATCH_OP_DUP:
00547 case MATCH_PAR_DUP:
00548 ++num_dups;
00549 break;
00550
00551 case ADDRESS:
00552 scan_operands (d, XEXP (part, 0), 1, 0);
00553 return;
00554
00555 case STRICT_LOW_PART:
00556 scan_operands (d, XEXP (part, 0), 0, 1);
00557 return;
00558
00559 default:
00560 break;
00561 }
00562
00563 format_ptr = GET_RTX_FORMAT (GET_CODE (part));
00564
00565 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (part)); i++)
00566 switch (*format_ptr++)
00567 {
00568 case 'e':
00569 case 'u':
00570 scan_operands (d, XEXP (part, i), 0, 0);
00571 break;
00572 case 'E':
00573 if (XVEC (part, i) != NULL)
00574 for (j = 0; j < XVECLEN (part, i); j++)
00575 scan_operands (d, XVECEXP (part, i, j), 0, 0);
00576 break;
00577 }
00578 }
00579
00580
00581
00582 static int
00583 compare_operands (d0, d1)
00584 struct operand_data *d0, *d1;
00585 {
00586 const char *p0, *p1;
00587
00588 p0 = d0->predicate;
00589 if (!p0)
00590 p0 = "";
00591 p1 = d1->predicate;
00592 if (!p1)
00593 p1 = "";
00594 if (strcmp (p0, p1) != 0)
00595 return 0;
00596
00597 p0 = d0->constraint;
00598 if (!p0)
00599 p0 = "";
00600 p1 = d1->constraint;
00601 if (!p1)
00602 p1 = "";
00603 if (strcmp (p0, p1) != 0)
00604 return 0;
00605
00606 if (d0->mode != d1->mode)
00607 return 0;
00608
00609 if (d0->strict_low != d1->strict_low)
00610 return 0;
00611
00612 if (d0->eliminable != d1->eliminable)
00613 return 0;
00614
00615 return 1;
00616 }
00617
00618
00619
00620
00621 static void
00622 place_operands (d)
00623 struct data *d;
00624 {
00625 struct operand_data *od, *od2;
00626 int i;
00627
00628 if (d->n_operands == 0)
00629 {
00630 d->operand_number = 0;
00631 return;
00632 }
00633
00634
00635 for (od = odata, i = 0; od; od = od->next, i = 0)
00636 if (compare_operands (od, &d->operand[0]))
00637 {
00638 od2 = od->next;
00639 i = 1;
00640 while (1)
00641 {
00642 if (i == d->n_operands)
00643 goto full_match;
00644 if (od2 == NULL)
00645 goto partial_match;
00646 if (! compare_operands (od2, &d->operand[i]))
00647 break;
00648 ++i, od2 = od2->next;
00649 }
00650 }
00651
00652
00653
00654 partial_match:
00655 d->operand_number = next_operand_number - i;
00656 for (; i < d->n_operands; ++i)
00657 {
00658 od2 = &d->operand[i];
00659 *odata_end = od2;
00660 odata_end = &od2->next;
00661 od2->index = next_operand_number++;
00662 }
00663 *odata_end = NULL;
00664 return;
00665
00666 full_match:
00667 d->operand_number = od->index;
00668 return;
00669 }
00670
00671
00672
00673
00674
00675
00676 static void
00677 process_template (d, template)
00678 struct data *d;
00679 const char *template;
00680 {
00681 const char *cp;
00682 int i;
00683
00684
00685 if (template[0] == '*')
00686 {
00687 d->template = 0;
00688 d->output_format = INSN_OUTPUT_FORMAT_FUNCTION;
00689
00690 printf ("\nstatic const char *output_%d PARAMS ((rtx *, rtx));\n",
00691 d->code_number);
00692 puts ("\nstatic const char *");
00693 printf ("output_%d (operands, insn)\n", d->code_number);
00694 puts (" rtx *operands ATTRIBUTE_UNUSED;");
00695 puts (" rtx insn ATTRIBUTE_UNUSED;");
00696 puts ("{");
00697
00698 puts (template + 1);
00699 puts ("}");
00700 }
00701
00702
00703
00704 else if (template[0] == '@')
00705 {
00706 d->template = 0;
00707 d->output_format = INSN_OUTPUT_FORMAT_MULTI;
00708
00709 printf ("\nstatic const char * const output_%d[] = {\n", d->code_number);
00710
00711 for (i = 0, cp = &template[1]; *cp; )
00712 {
00713 while (ISSPACE (*cp))
00714 cp++;
00715
00716 printf (" \"");
00717 #ifndef SGI_MONGOOSE
00718 while (!IS_VSPACE (*cp) && *cp != '\0')
00719 #else
00720 while (*cp != '\n' && *cp != '\0')
00721 #endif
00722 {
00723 putchar (*cp);
00724 cp++;
00725 }
00726
00727 printf ("\",\n");
00728 i++;
00729 }
00730 if (i == 1)
00731 message_with_line (d->lineno,
00732 "'@' is redundant for output template with single alternative");
00733 if (i != d->n_alternatives)
00734 {
00735 message_with_line (d->lineno,
00736 "wrong number of alternatives in the output template");
00737 have_error = 1;
00738 }
00739
00740 printf ("};\n");
00741 }
00742 else
00743 {
00744 d->template = template;
00745 d->output_format = INSN_OUTPUT_FORMAT_SINGLE;
00746 }
00747 }
00748
00749
00750
00751 static void
00752 validate_insn_alternatives (d)
00753 struct data *d;
00754 {
00755 int n = 0, start;
00756
00757
00758
00759 for (start = 0; start < d->n_operands; start++)
00760 if (d->operand[start].n_alternatives > 0)
00761 {
00762 if (n == 0)
00763 n = d->operand[start].n_alternatives;
00764 else if (n != d->operand[start].n_alternatives)
00765 {
00766 message_with_line (d->lineno,
00767 "wrong number of alternatives in operand %d",
00768 start);
00769 have_error = 1;
00770 }
00771 }
00772
00773
00774 d->n_alternatives = n;
00775 }
00776
00777
00778
00779 static void
00780 validate_insn_operands (d)
00781 struct data *d;
00782 {
00783 int i;
00784
00785 for (i = 0; i < d->n_operands; ++i)
00786 if (d->operand[i].seen == 0)
00787 {
00788 message_with_line (d->lineno, "missing operand %d", i);
00789 have_error = 1;
00790 }
00791 }
00792
00793
00794
00795
00796
00797 static void
00798 gen_insn (insn, lineno)
00799 rtx insn;
00800 int lineno;
00801 {
00802 struct data *d = (struct data *) xmalloc (sizeof (struct data));
00803 int i;
00804
00805 d->code_number = next_code_number;
00806 d->index_number = next_index_number;
00807 d->lineno = lineno;
00808 if (XSTR (insn, 0)[0])
00809 d->name = XSTR (insn, 0);
00810 else
00811 d->name = 0;
00812
00813
00814
00815 d->next = 0;
00816 *idata_end = d;
00817 idata_end = &d->next;
00818
00819 max_opno = -1;
00820 num_dups = 0;
00821 memset (d->operand, 0, sizeof (d->operand));
00822
00823 for (i = 0; i < XVECLEN (insn, 1); i++)
00824 scan_operands (d, XVECEXP (insn, 1, i), 0, 0);
00825
00826 d->n_operands = max_opno + 1;
00827 d->n_dups = num_dups;
00828
00829 validate_insn_operands (d);
00830 validate_insn_alternatives (d);
00831 place_operands (d);
00832 process_template (d, XTMPL (insn, 3));
00833 }
00834
00835
00836
00837
00838
00839 static void
00840 gen_peephole (peep, lineno)
00841 rtx peep;
00842 int lineno;
00843 {
00844 struct data *d = (struct data *) xmalloc (sizeof (struct data));
00845 int i;
00846
00847 d->code_number = next_code_number;
00848 d->index_number = next_index_number;
00849 d->lineno = lineno;
00850 d->name = 0;
00851
00852
00853
00854 d->next = 0;
00855 *idata_end = d;
00856 idata_end = &d->next;
00857
00858 max_opno = -1;
00859 num_dups = 0;
00860 memset (d->operand, 0, sizeof (d->operand));
00861
00862
00863
00864
00865 for (i = 0; i < XVECLEN (peep, 0); i++)
00866 scan_operands (d, XVECEXP (peep, 0, i), 0, 0);
00867
00868 d->n_operands = max_opno + 1;
00869 d->n_dups = 0;
00870
00871 validate_insn_alternatives (d);
00872 place_operands (d);
00873 process_template (d, XTMPL (peep, 2));
00874 }
00875
00876
00877
00878
00879 static void
00880 gen_expand (insn, lineno)
00881 rtx insn;
00882 int lineno;
00883 {
00884 struct data *d = (struct data *) xmalloc (sizeof (struct data));
00885 int i;
00886
00887 d->code_number = next_code_number;
00888 d->index_number = next_index_number;
00889 d->lineno = lineno;
00890 if (XSTR (insn, 0)[0])
00891 d->name = XSTR (insn, 0);
00892 else
00893 d->name = 0;
00894
00895
00896
00897 d->next = 0;
00898 *idata_end = d;
00899 idata_end = &d->next;
00900
00901 max_opno = -1;
00902 num_dups = 0;
00903 memset (d->operand, 0, sizeof (d->operand));
00904
00905
00906
00907
00908 if (XVEC (insn, 1))
00909 for (i = 0; i < XVECLEN (insn, 1); i++)
00910 scan_operands (d, XVECEXP (insn, 1, i), 0, 0);
00911
00912 d->n_operands = max_opno + 1;
00913 d->n_dups = num_dups;
00914 d->template = 0;
00915 d->output_format = INSN_OUTPUT_FORMAT_NONE;
00916
00917 validate_insn_alternatives (d);
00918 place_operands (d);
00919 }
00920
00921
00922
00923
00924 static void
00925 gen_split (split, lineno)
00926 rtx split;
00927 int lineno;
00928 {
00929 struct data *d = (struct data *) xmalloc (sizeof (struct data));
00930 int i;
00931
00932 d->code_number = next_code_number;
00933 d->index_number = next_index_number;
00934 d->lineno = lineno;
00935 d->name = 0;
00936
00937
00938
00939 d->next = 0;
00940 *idata_end = d;
00941 idata_end = &d->next;
00942
00943 max_opno = -1;
00944 num_dups = 0;
00945 memset (d->operand, 0, sizeof (d->operand));
00946
00947
00948
00949
00950 for (i = 0; i < XVECLEN (split, 0); i++)
00951 scan_operands (d, XVECEXP (split, 0, i), 0, 0);
00952
00953 d->n_operands = max_opno + 1;
00954 d->n_dups = 0;
00955 d->n_alternatives = 0;
00956 d->template = 0;
00957 d->output_format = INSN_OUTPUT_FORMAT_NONE;
00958
00959 place_operands (d);
00960 }
00961
00962 extern int main PARAMS ((int, char **));
00963
00964 int
00965 main (argc, argv)
00966 int argc;
00967 char **argv;
00968 {
00969 rtx desc;
00970
00971 progname = "genoutput";
00972
00973 if (argc <= 1)
00974 fatal ("no input file name");
00975
00976 if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
00977 return (FATAL_EXIT_CODE);
00978
00979 output_prologue ();
00980 next_code_number = 0;
00981 next_index_number = 0;
00982
00983
00984
00985 while (1)
00986 {
00987 int line_no;
00988
00989 desc = read_md_rtx (&line_no, &next_code_number);
00990 if (desc == NULL)
00991 break;
00992
00993 if (GET_CODE (desc) == DEFINE_INSN)
00994 gen_insn (desc, line_no);
00995 if (GET_CODE (desc) == DEFINE_PEEPHOLE)
00996 gen_peephole (desc, line_no);
00997 if (GET_CODE (desc) == DEFINE_EXPAND)
00998 gen_expand (desc, line_no);
00999 if (GET_CODE (desc) == DEFINE_SPLIT
01000 || GET_CODE (desc) == DEFINE_PEEPHOLE2)
01001 gen_split (desc, line_no);
01002 next_index_number++;
01003 }
01004
01005 printf("\n\n");
01006 output_predicate_decls ();
01007 output_operand_data ();
01008 output_insn_data ();
01009 output_get_insn_name ();
01010
01011 fflush (stdout);
01012 return (ferror (stdout) != 0 || have_error
01013 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
01014 }
01015
01016
01017
01018
01019 static int
01020 n_occurrences (c, s)
01021 int c;
01022 const char *s;
01023 {
01024 int n = 0;
01025
01026 if (s == 0 || *s == '\0')
01027 return -1;
01028
01029 while (*s)
01030 n += (*s++ == c);
01031
01032 return n;
01033 }
01034
01035
01036
01037
01038 static const char *
01039 strip_whitespace (s)
01040 const char *s;
01041 {
01042 char *p, *q;
01043 char ch;
01044
01045 if (s == 0)
01046 return 0;
01047
01048 p = q = xmalloc (strlen (s) + 1);
01049 while ((ch = *s++) != '\0')
01050 if (! ISSPACE (ch))
01051 *p++ = ch;
01052
01053 *p = '\0';
01054 return q;
01055 }