]>
Commit | Line | Data |
---|---|---|
41299f41 | 1 | /* Generate from machine description: |
41299f41 TW |
2 | - some macros CODE_FOR_... giving the insn_code_number value |
3 | for each of the defined standard insn names. | |
d050d723 | 4 | Copyright (C) 1987, 1991, 1995, 1998, |
3d7aafde | 5 | 1999, 2000, 2001, 2003 Free Software Foundation, Inc. |
41299f41 | 6 | |
1322177d | 7 | This file is part of GCC. |
41299f41 | 8 | |
1322177d LB |
9 | GCC is free software; you can redistribute it and/or modify it under |
10 | the terms of the GNU General Public License as published by the Free | |
11 | Software Foundation; either version 2, or (at your option) any later | |
12 | version. | |
41299f41 | 13 | |
1322177d LB |
14 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 | for more details. | |
41299f41 TW |
18 | |
19 | You should have received a copy of the GNU General Public License | |
1322177d LB |
20 | along with GCC; see the file COPYING. If not, write to the Free |
21 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
22 | 02111-1307, USA. */ | |
41299f41 TW |
23 | |
24 | ||
4977bab6 | 25 | #include "bconfig.h" |
0b93b64e | 26 | #include "system.h" |
4977bab6 ZW |
27 | #include "coretypes.h" |
28 | #include "tm.h" | |
41299f41 | 29 | #include "rtl.h" |
f8b6598e | 30 | #include "errors.h" |
c88c0d42 | 31 | #include "gensupport.h" |
41299f41 | 32 | |
41299f41 | 33 | static void |
3d7aafde | 34 | gen_insn (rtx insn, int code) |
41299f41 | 35 | { |
2199e5fa ZW |
36 | const char *name = XSTR (insn, 0); |
37 | int truth = maybe_eval_c_test (XSTR (insn, 2)); | |
38 | ||
6b6ca844 RK |
39 | /* Don't mention instructions whose names are the null string |
40 | or begin with '*'. They are in the machine description just | |
41 | to be recognized. */ | |
e78d8e51 | 42 | if (name[0] != 0 && name[0] != '*') |
2199e5fa ZW |
43 | { |
44 | if (truth == 0) | |
45 | printf ("#define CODE_FOR_%s CODE_FOR_nothing\n", name); | |
46 | else | |
47 | printf (" CODE_FOR_%s = %d,\n", name, code); | |
48 | } | |
41299f41 TW |
49 | } |
50 | ||
41299f41 | 51 | int |
3d7aafde | 52 | main (int argc, char **argv) |
41299f41 TW |
53 | { |
54 | rtx desc; | |
41299f41 | 55 | |
f8b6598e | 56 | progname = "gencodes"; |
41299f41 | 57 | |
2199e5fa ZW |
58 | /* We need to see all the possibilities. Elided insns may have |
59 | direct references to CODE_FOR_xxx in C code. */ | |
60 | insn_elision = 0; | |
61 | ||
41299f41 | 62 | if (argc <= 1) |
1f978f5f | 63 | fatal ("no input file name"); |
41299f41 | 64 | |
04d8aa70 | 65 | if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) |
c88c0d42 | 66 | return (FATAL_EXIT_CODE); |
41299f41 | 67 | |
e78d8e51 ZW |
68 | puts ("\ |
69 | /* Generated automatically by the program `gencodes'\n\ | |
70 | from the machine description file `md'. */\n\ | |
71 | \n\ | |
72 | #ifndef GCC_INSN_CODES_H\n\ | |
73 | #define GCC_INSN_CODES_H\n\ | |
74 | \n\ | |
75 | enum insn_code {"); | |
41299f41 TW |
76 | |
77 | /* Read the machine description. */ | |
78 | ||
41299f41 TW |
79 | while (1) |
80 | { | |
c88c0d42 | 81 | int line_no; |
e78d8e51 | 82 | int insn_code_number; |
c88c0d42 CP |
83 | |
84 | desc = read_md_rtx (&line_no, &insn_code_number); | |
85 | if (desc == NULL) | |
41299f41 | 86 | break; |
41299f41 | 87 | |
41299f41 | 88 | if (GET_CODE (desc) == DEFINE_INSN || GET_CODE (desc) == DEFINE_EXPAND) |
2199e5fa | 89 | gen_insn (desc, insn_code_number); |
41299f41 TW |
90 | } |
91 | ||
2199e5fa | 92 | puts (" CODE_FOR_nothing\n\ |
e78d8e51 ZW |
93 | };\n\ |
94 | \n\ | |
95 | #endif /* GCC_INSN_CODES_H */"); | |
0313e85b ZW |
96 | |
97 | if (ferror (stdout) || fflush (stdout) || fclose (stdout)) | |
98 | return FATAL_EXIT_CODE; | |
41299f41 | 99 | |
0313e85b | 100 | return SUCCESS_EXIT_CODE; |
41299f41 | 101 | } |
a995e389 RH |
102 | |
103 | /* Define this so we can link with print-rtl.o to get debug_rtx function. */ | |
9f6709e0 | 104 | |
a995e389 | 105 | const char * |
3d7aafde | 106 | get_insn_name (int code ATTRIBUTE_UNUSED) |
a995e389 RH |
107 | { |
108 | return NULL; | |
109 | } |