summaryrefslogtreecommitdiff
path: root/gcc/gencodes.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/gencodes.c')
-rw-r--r--gcc/gencodes.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/gcc/gencodes.c b/gcc/gencodes.c
index 2610a12325f..ffcd1876215 100644
--- a/gcc/gencodes.c
+++ b/gcc/gencodes.c
@@ -28,20 +28,18 @@ Boston, MA 02111-1307, USA. */
#include "errors.h"
#include "gensupport.h"
-static int insn_code_number;
-
-static void gen_insn PARAMS ((rtx));
+static void gen_insn PARAMS ((const char *, int));
static void
-gen_insn (insn)
- rtx insn;
+gen_insn (name, code)
+ const char *name;
+ int code;
{
/* Don't mention instructions whose names are the null string
or begin with '*'. They are in the machine description just
to be recognized. */
- if (XSTR (insn, 0)[0] != 0 && XSTR (insn, 0)[0] != '*')
- printf (" CODE_FOR_%s = %d,\n", XSTR (insn, 0),
- insn_code_number);
+ if (name[0] != 0 && name[0] != '*')
+ printf (" CODE_FOR_%s = %d,\n", name, code);
}
extern int main PARAMS ((int, char **));
@@ -61,33 +59,34 @@ main (argc, argv)
if (init_md_reader (argv[1]) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE);
- puts ("/* Generated automatically by the program `gencodes'");
- puts (" from the machine description file `md'. */\n");
- puts ("#ifndef GCC_INSN_CODES_H");
- puts ("#define GCC_INSN_CODES_H\n");
+ puts ("\
+/* Generated automatically by the program `gencodes'\n\
+ from the machine description file `md'. */\n\
+\n\
+#ifndef GCC_INSN_CODES_H\n\
+#define GCC_INSN_CODES_H\n\
+\n\
+enum insn_code {");
/* Read the machine description. */
- insn_code_number = 0;
- printf ("enum insn_code {\n");
-
while (1)
{
int line_no;
+ int insn_code_number;
desc = read_md_rtx (&line_no, &insn_code_number);
if (desc == NULL)
break;
if (GET_CODE (desc) == DEFINE_INSN || GET_CODE (desc) == DEFINE_EXPAND)
- gen_insn (desc);
+ gen_insn (XSTR (desc, 0), insn_code_number);
}
- printf (" CODE_FOR_nothing = %d };\n", insn_code_number + 1);
-
- printf ("\n#define MAX_INSN_CODE ((int) CODE_FOR_nothing)\n\n");
-
- puts("\n#endif /* GCC_INSN_CODES_H */");
+ puts ("CODE_FOR_nothing\n\
+};\n\
+\n\
+#endif /* GCC_INSN_CODES_H */");
if (ferror (stdout) || fflush (stdout) || fclose (stdout))
return FATAL_EXIT_CODE;