1994-06-24 11:31:16 +00:00
|
|
|
/* $Id$ */
|
1987-03-09 19:15:41 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
|
|
|
|
#include <stdbool.h>
|
2006-07-22 00:46:16 +00:00
|
|
|
#include <stdlib.h>
|
1984-11-26 14:35:32 +00:00
|
|
|
#include <stdio.h>
|
2017-11-14 22:04:01 +00:00
|
|
|
#include <string.h>
|
1984-11-26 14:35:32 +00:00
|
|
|
|
|
|
|
/* MAKE ITEMS TABLE
|
|
|
|
*
|
|
|
|
* This program is used by the register allocation phase of the optimizer
|
|
|
|
* to make the file itemtab.h. It reads two files:
|
|
|
|
* - the em_mnem.h file, containing the definitions of the
|
|
|
|
* EM mnemonics
|
|
|
|
* - the item-file, containing tuples:
|
|
|
|
* (mnemonic, item_type)
|
|
|
|
* The output (standard output) is a C array.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
void error(const char *s)
|
|
|
|
{
|
|
|
|
fprintf(stderr,"%s\n",s);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
1984-11-26 14:35:32 +00:00
|
|
|
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
void convert(FILE *mnemfile, FILE *itemfile)
|
1984-11-26 14:35:32 +00:00
|
|
|
{
|
|
|
|
char mnem1[20], mnem2[20],def[20],itemtype[20];
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
int opc,index;
|
|
|
|
bool newcl;
|
1984-11-26 14:35:32 +00:00
|
|
|
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
newcl = true;
|
1984-11-26 14:35:32 +00:00
|
|
|
printf("struct item_descr itemtab[] = {\n");
|
|
|
|
for (;;) {
|
2018-06-02 18:51:41 +00:00
|
|
|
fscanf(mnemfile,"%19s%19s%d",def,mnem1,&opc);
|
1984-11-26 14:35:32 +00:00
|
|
|
/* read a line like "#define op_aar 1" */
|
|
|
|
if (feof(mnemfile)) break;
|
|
|
|
if (strcmp(def,"#define") != 0) {
|
|
|
|
error("bad mnemonic file, #define expected");
|
|
|
|
}
|
|
|
|
if (newcl) {
|
2018-06-02 18:51:41 +00:00
|
|
|
fscanf(itemfile,"%19s%19s%d",mnem2,itemtype,&index);
|
1984-11-26 14:35:32 +00:00
|
|
|
/* read a line like "op_loc CONST 4" */
|
|
|
|
}
|
|
|
|
if (feof(itemfile) || strcmp(mnem1,mnem2) != 0) {
|
|
|
|
/* there is no line for this mnemonic, so
|
|
|
|
* it has no type.
|
|
|
|
*/
|
1990-08-20 15:32:29 +00:00
|
|
|
printf("{NO_ITEM,0}, /* %s */\n", mnem1);
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
newcl = false;
|
1984-11-26 14:35:32 +00:00
|
|
|
} else {
|
1990-08-20 15:32:29 +00:00
|
|
|
printf("{%s,%d}, /* %s */\n",itemtype,index, mnem1);
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
newcl = true;
|
1984-11-26 14:35:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("};\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
int main(int argc, char *argv[])
|
1984-11-26 14:35:32 +00:00
|
|
|
{
|
|
|
|
FILE *f1,*f2;
|
|
|
|
|
|
|
|
if (argc != 3) {
|
|
|
|
error("usage: makeitems mnemfile itemfile");
|
|
|
|
}
|
2022-07-17 18:47:53 +00:00
|
|
|
if ((f1 = fopen(argv[1],"rb")) == NULL) {
|
1984-11-26 14:35:32 +00:00
|
|
|
error("cannot open mnemonic file");
|
|
|
|
}
|
2022-07-17 18:47:53 +00:00
|
|
|
if ((f2 = fopen(argv[2],"rb")) == NULL) {
|
1984-11-26 14:35:32 +00:00
|
|
|
error("cannot open item file");
|
|
|
|
}
|
|
|
|
convert(f1,f2);
|
1987-03-09 13:14:32 +00:00
|
|
|
exit(0);
|
1984-11-26 14:35:32 +00:00
|
|
|
}
|