]>
Commit | Line | Data |
---|---|---|
3439974c | 1 | /* Generate from machine description: |
3439974c | 2 | - some macros CODE_FOR_... giving the insn_code_number value |
3 | for each of the defined standard insn names. | |
fbd26352 | 4 | Copyright (C) 1987-2019 Free Software Foundation, Inc. |
3439974c | 5 | |
f12b58b3 | 6 | This file is part of GCC. |
3439974c | 7 | |
f12b58b3 | 8 | GCC is free software; you can redistribute it and/or modify it under |
9 | the terms of the GNU General Public License as published by the Free | |
8c4c00c1 | 10 | Software Foundation; either version 3, or (at your option) any later |
f12b58b3 | 11 | version. |
3439974c | 12 | |
f12b58b3 | 13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | for more details. | |
3439974c | 17 | |
18 | You should have received a copy of the GNU General Public License | |
8c4c00c1 | 19 | along with GCC; see the file COPYING3. If not see |
20 | <http://www.gnu.org/licenses/>. */ | |
3439974c | 21 | |
22 | ||
805e22b2 | 23 | #include "bconfig.h" |
5ce88198 | 24 | #include "system.h" |
805e22b2 | 25 | #include "coretypes.h" |
26 | #include "tm.h" | |
3439974c | 27 | #include "rtl.h" |
04b58880 | 28 | #include "errors.h" |
c5ddd6b5 | 29 | #include "gensupport.h" |
3439974c | 30 | |
3439974c | 31 | static void |
c04601c1 | 32 | gen_insn (md_rtx_info *info) |
3439974c | 33 | { |
c04601c1 | 34 | const char *name = XSTR (info->def, 0); |
35 | int truth = maybe_eval_c_test (XSTR (info->def, 2)); | |
b70bd542 | 36 | |
a0761610 | 37 | /* Don't mention instructions whose names are the null string |
38 | or begin with '*'. They are in the machine description just | |
39 | to be recognized. */ | |
d8fc4d0b | 40 | if (name[0] != 0 && name[0] != '*') |
b70bd542 | 41 | { |
42 | if (truth == 0) | |
9fdbc432 | 43 | printf (",\n CODE_FOR_%s = CODE_FOR_nothing", name); |
b70bd542 | 44 | else |
9fdbc432 | 45 | printf (",\n CODE_FOR_%s = %d", name, info->index); |
b70bd542 | 46 | } |
3439974c | 47 | } |
48 | ||
3439974c | 49 | int |
16570c04 | 50 | main (int argc, const char **argv) |
3439974c | 51 | { |
04b58880 | 52 | progname = "gencodes"; |
3439974c | 53 | |
b70bd542 | 54 | /* We need to see all the possibilities. Elided insns may have |
55 | direct references to CODE_FOR_xxx in C code. */ | |
56 | insn_elision = 0; | |
57 | ||
77ba95d0 | 58 | if (!init_rtx_reader_args (argc, argv)) |
c5ddd6b5 | 59 | return (FATAL_EXIT_CODE); |
3439974c | 60 | |
9fdbc432 | 61 | printf ("\ |
d8fc4d0b | 62 | /* Generated automatically by the program `gencodes'\n\ |
63 | from the machine description file `md'. */\n\ | |
64 | \n\ | |
65 | #ifndef GCC_INSN_CODES_H\n\ | |
66 | #define GCC_INSN_CODES_H\n\ | |
67 | \n\ | |
5ab7f285 | 68 | enum insn_code {\n\ |
9fdbc432 | 69 | CODE_FOR_nothing = 0"); |
3439974c | 70 | |
71 | /* Read the machine description. */ | |
72 | ||
c04601c1 | 73 | md_rtx_info info; |
74 | while (read_md_rtx (&info)) | |
75 | switch (GET_CODE (info.def)) | |
76 | { | |
77 | case DEFINE_INSN: | |
78 | case DEFINE_EXPAND: | |
79 | gen_insn (&info); | |
3439974c | 80 | break; |
3439974c | 81 | |
c04601c1 | 82 | default: |
83 | break; | |
3439974c | 84 | } |
85 | ||
9fdbc432 | 86 | printf ("\n};\n\ |
d8fc4d0b | 87 | \n\ |
9fdbc432 | 88 | const unsigned int NUM_INSN_CODES = %d;\n\ |
89 | #endif /* GCC_INSN_CODES_H */\n", get_num_insn_codes ()); | |
d0c809e1 | 90 | |
91 | if (ferror (stdout) || fflush (stdout) || fclose (stdout)) | |
92 | return FATAL_EXIT_CODE; | |
3439974c | 93 | |
d0c809e1 | 94 | return SUCCESS_EXIT_CODE; |
3439974c | 95 | } |