1 /* $Id: makeitems.c,v 1.6 1994/06/24 10:27:15 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
10 * This program is used by the register allocation phase of the optimizer
11 * to make the file itemtab.h. It reads two files:
12 * - the em_mnem.h file, containing the definitions of the
14 * - the item-file, containing tuples:
15 * (mnemonic, item_type)
16 * The output (standard output) is a C array.
23 convert(mnemfile,itemfile)
24 FILE *mnemfile, *itemfile;
26 char mnem1[20], mnem2[20],def[20],itemtype[20];
30 printf("struct item_descr itemtab[] = {\n");
32 fscanf(mnemfile,"%s%s%d",def,mnem1,&opc);
33 /* read a line like "#define op_aar 1" */
34 if (feof(mnemfile)) break;
35 if (strcmp(def,"#define") != 0) {
36 error("bad mnemonic file, #define expected");
39 fscanf(itemfile,"%s%s%d",mnem2,itemtype,&index);
40 /* read a line like "op_loc CONST 4" */
42 if (feof(itemfile) || strcmp(mnem1,mnem2) != 0) {
43 /* there is no line for this mnemonic, so
46 printf("{NO_ITEM,0}, /* %s */\n", mnem1);
49 printf("{%s,%d}, /* %s */\n",itemtype,index, mnem1);
61 fprintf(stderr,"%s\n",s);
73 error("usage: makeitems mnemfile itemfile");
75 if ((f1 = fopen(argv[1],"r")) == NULL) {
76 error("cannot open mnemonic file");
78 if ((f2 = fopen(argv[2],"r")) == NULL) {
79 error("cannot open item file");