]>
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. | |
9dcd6f09 NC |
4 | Copyright (C) 1987, 1991, 1995, 1998, 1999, 2000, 2001, 2003, |
5 | 2004, 2007 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 | |
9dcd6f09 | 11 | Software Foundation; either version 3, or (at your option) any later |
1322177d | 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 | |
9dcd6f09 NC |
20 | along with GCC; see the file COPYING3. If not see |
21 | <http://www.gnu.org/licenses/>. */ | |
41299f41 TW |
22 | |
23 | ||
4977bab6 | 24 | #include "bconfig.h" |
0b93b64e | 25 | #include "system.h" |
4977bab6 ZW |
26 | #include "coretypes.h" |
27 | #include "tm.h" | |
41299f41 | 28 | #include "rtl.h" |
f8b6598e | 29 | #include "errors.h" |
c88c0d42 | 30 | #include "gensupport.h" |
41299f41 | 31 | |
41299f41 | 32 | static void |
3d7aafde | 33 | gen_insn (rtx insn, int code) |
41299f41 | 34 | { |
2199e5fa ZW |
35 | const char *name = XSTR (insn, 0); |
36 | int truth = maybe_eval_c_test (XSTR (insn, 2)); | |
37 | ||
6b6ca844 RK |
38 | /* Don't mention instructions whose names are the null string |
39 | or begin with '*'. They are in the machine description just | |
40 | to be recognized. */ | |
e78d8e51 | 41 | if (name[0] != 0 && name[0] != '*') |
2199e5fa ZW |
42 | { |
43 | if (truth == 0) | |
44 | printf ("#define CODE_FOR_%s CODE_FOR_nothing\n", name); | |
45 | else | |
46 | printf (" CODE_FOR_%s = %d,\n", name, code); | |
47 | } | |
41299f41 TW |
48 | } |
49 | ||
41299f41 | 50 | int |
3d7aafde | 51 | main (int argc, char **argv) |
41299f41 TW |
52 | { |
53 | rtx desc; | |
41299f41 | 54 | |
f8b6598e | 55 | progname = "gencodes"; |
41299f41 | 56 | |
2199e5fa ZW |
57 | /* We need to see all the possibilities. Elided insns may have |
58 | direct references to CODE_FOR_xxx in C code. */ | |
59 | insn_elision = 0; | |
60 | ||
04d8aa70 | 61 | if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) |
c88c0d42 | 62 | return (FATAL_EXIT_CODE); |
41299f41 | 63 | |
e78d8e51 ZW |
64 | puts ("\ |
65 | /* Generated automatically by the program `gencodes'\n\ | |
66 | from the machine description file `md'. */\n\ | |
67 | \n\ | |
68 | #ifndef GCC_INSN_CODES_H\n\ | |
69 | #define GCC_INSN_CODES_H\n\ | |
70 | \n\ | |
71 | enum insn_code {"); | |
41299f41 TW |
72 | |
73 | /* Read the machine description. */ | |
74 | ||
41299f41 TW |
75 | while (1) |
76 | { | |
c88c0d42 | 77 | int line_no; |
e78d8e51 | 78 | int insn_code_number; |
c88c0d42 CP |
79 | |
80 | desc = read_md_rtx (&line_no, &insn_code_number); | |
81 | if (desc == NULL) | |
41299f41 | 82 | break; |
41299f41 | 83 | |
41299f41 | 84 | if (GET_CODE (desc) == DEFINE_INSN || GET_CODE (desc) == DEFINE_EXPAND) |
2199e5fa | 85 | gen_insn (desc, insn_code_number); |
41299f41 TW |
86 | } |
87 | ||
2199e5fa | 88 | puts (" CODE_FOR_nothing\n\ |
e78d8e51 ZW |
89 | };\n\ |
90 | \n\ | |
91 | #endif /* GCC_INSN_CODES_H */"); | |
0313e85b ZW |
92 | |
93 | if (ferror (stdout) || fflush (stdout) || fclose (stdout)) | |
94 | return FATAL_EXIT_CODE; | |
41299f41 | 95 | |
0313e85b | 96 | return SUCCESS_EXIT_CODE; |
41299f41 | 97 | } |