]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gencodes.c
c++: Handle multiple aggregate overloads [PR95319].
[thirdparty/gcc.git] / gcc / gencodes.c
CommitLineData
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.
8d9254fc 4 Copyright (C) 1987-2020 Free Software Foundation, Inc.
41299f41 5
1322177d 6This file is part of GCC.
41299f41 7
1322177d
LB
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
9dcd6f09 10Software Foundation; either version 3, or (at your option) any later
1322177d 11version.
41299f41 12
1322177d
LB
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
41299f41
TW
17
18You should have received a copy of the GNU General Public License
9dcd6f09
NC
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
41299f41
TW
21
22
4977bab6 23#include "bconfig.h"
0b93b64e 24#include "system.h"
4977bab6
ZW
25#include "coretypes.h"
26#include "tm.h"
41299f41 27#include "rtl.h"
f8b6598e 28#include "errors.h"
c88c0d42 29#include "gensupport.h"
41299f41 30
41299f41 31static void
5d2d3e43 32gen_insn (md_rtx_info *info)
41299f41 33{
5d2d3e43
RS
34 const char *name = XSTR (info->def, 0);
35 int truth = maybe_eval_c_test (XSTR (info->def, 2));
2199e5fa 36
6b6ca844
RK
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. */
e78d8e51 40 if (name[0] != 0 && name[0] != '*')
2199e5fa
ZW
41 {
42 if (truth == 0)
523ba738 43 printf (",\n CODE_FOR_%s = CODE_FOR_nothing", name);
2199e5fa 44 else
523ba738 45 printf (",\n CODE_FOR_%s = %d", name, info->index);
2199e5fa 46 }
41299f41
TW
47}
48
41299f41 49int
66b0fe8f 50main (int argc, const char **argv)
41299f41 51{
f8b6598e 52 progname = "gencodes";
41299f41 53
2199e5fa
ZW
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
600ab3fc 58 if (!init_rtx_reader_args (argc, argv))
c88c0d42 59 return (FATAL_EXIT_CODE);
41299f41 60
523ba738 61 printf ("\
e78d8e51
ZW
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\
e714561a 68enum insn_code {\n\
523ba738 69 CODE_FOR_nothing = 0");
41299f41
TW
70
71 /* Read the machine description. */
72
5d2d3e43
RS
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);
41299f41 80 break;
41299f41 81
5d2d3e43
RS
82 default:
83 break;
41299f41
TW
84 }
85
523ba738 86 printf ("\n};\n\
e78d8e51 87\n\
523ba738
RS
88const unsigned int NUM_INSN_CODES = %d;\n\
89#endif /* GCC_INSN_CODES_H */\n", get_num_insn_codes ());
0313e85b
ZW
90
91 if (ferror (stdout) || fflush (stdout) || fclose (stdout))
92 return FATAL_EXIT_CODE;
41299f41 93
0313e85b 94 return SUCCESS_EXIT_CODE;
41299f41 95}