1 /* Generate from machine description:
2 - some macros CODE_FOR_... giving the insn_code_number value
3 for each of the defined standard insn names.
4 Copyright (C) 1987, 1991, 1995, 1998 Free Software Foundation, Inc.
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
29 static struct obstack obstack
;
30 struct obstack
*rtl_obstack
= &obstack
;
32 #define obstack_chunk_alloc xmalloc
33 #define obstack_chunk_free free
39 void fatal
PVPROTO((char *, ...));
41 /* We must not provide any prototype here, even if ANSI C. */
47 static int insn_code_number
;
53 /* Don't mention instructions whose names are the null string
54 or begin with '*'. They are in the machine description just
56 if (XSTR (insn
, 0)[0] != 0 && XSTR (insn
, 0)[0] != '*')
57 printf (" CODE_FOR_%s = %d,\n", XSTR (insn
, 0),
65 register char *val
= (char *) malloc (size
);
68 fatal ("virtual memory exhausted");
77 char *result
= (char *) realloc (ptr
, size
);
79 fatal ("virtual memory exhausted");
85 fatal
VPROTO((char *s
, ...))
87 #ifndef ANSI_PROTOTYPES
94 #ifndef ANSI_PROTOTYPES
95 s
= va_arg (ap
, char *);
98 fprintf (stderr
, "gencodes: ");
99 vfprintf (stderr
, s
, ap
);
101 fprintf (stderr
, "\n");
102 exit (FATAL_EXIT_CODE
);
104 #else /* not HAVE_VPRINTF */
110 fprintf (stderr
, "gencodes: ");
111 fprintf (stderr
, s
, a1
, a2
);
112 fprintf (stderr
, "\n");
113 exit (FATAL_EXIT_CODE
);
115 #endif /* not HAVE_VPRINTF */
117 /* More 'friendly' abort that prints the line and file.
118 config.h can #define abort fancy_abort if you like that sort of thing. */
123 fatal ("Internal gcc abort.");
135 obstack_init (rtl_obstack
);
138 fatal ("No input file name.");
140 infile
= fopen (argv
[1], "r");
144 exit (FATAL_EXIT_CODE
);
149 printf ("/* Generated automatically by the program `gencodes'\n\
150 from the machine description file `md'. */\n\n");
152 printf ("#ifndef MAX_INSN_CODE\n\n");
154 /* Read the machine description. */
156 insn_code_number
= 0;
157 printf ("enum insn_code {\n");
161 c
= read_skip_spaces (infile
);
166 desc
= read_rtx (infile
);
167 if (GET_CODE (desc
) == DEFINE_INSN
|| GET_CODE (desc
) == DEFINE_EXPAND
)
172 if (GET_CODE (desc
) == DEFINE_PEEPHOLE
173 || GET_CODE (desc
) == DEFINE_SPLIT
)
179 printf (" CODE_FOR_nothing };\n");
181 printf ("\n#define MAX_INSN_CODE ((int) CODE_FOR_nothing)\n");
183 printf ("#endif /* MAX_INSN_CODE */\n");
186 exit (ferror (stdout
) != 0 ? FATAL_EXIT_CODE
: SUCCESS_EXIT_CODE
);