* xcoffout.c (xcoff_tls_data_section_name): Define.
[official-gcc.git] / gcc / gencodes.c
blobe95eb98cb88b0c47dc0acd7c0b98f627c013c527
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, 1999, 2000, 2001, 2003,
5 2004, 2007, 2010, 2012 Free Software Foundation, Inc.
7 This file is part of GCC.
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 3, or (at your option) any later
12 version.
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.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
24 #include "bconfig.h"
25 #include "system.h"
26 #include "coretypes.h"
27 #include "tm.h"
28 #include "rtl.h"
29 #include "errors.h"
30 #include "gensupport.h"
32 static void
33 gen_insn (rtx insn, int code)
35 const char *name = XSTR (insn, 0);
36 int truth = maybe_eval_c_test (XSTR (insn, 2));
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. */
41 if (name[0] != 0 && name[0] != '*')
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);
50 int
51 main (int argc, char **argv)
53 rtx desc;
55 progname = "gencodes";
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;
61 if (!init_rtx_reader_args (argc, argv))
62 return (FATAL_EXIT_CODE);
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 {\n\
72 CODE_FOR_nothing = 0,\n");
74 /* Read the machine description. */
76 while (1)
78 int line_no;
79 int insn_code_number;
81 desc = read_md_rtx (&line_no, &insn_code_number);
82 if (desc == NULL)
83 break;
85 if (GET_CODE (desc) == DEFINE_INSN || GET_CODE (desc) == DEFINE_EXPAND)
86 gen_insn (desc, insn_code_number);
89 puts (" LAST_INSN_CODE\n\
90 };\n\
91 \n\
92 #endif /* GCC_INSN_CODES_H */");
94 if (ferror (stdout) || fflush (stdout) || fclose (stdout))
95 return FATAL_EXIT_CODE;
97 return SUCCESS_EXIT_CODE;