comparison gcc/genenums.c @ 68:561a7518be6b

update gcc-4.6
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Sun, 21 Aug 2011 07:07:55 +0900
parents
children 04ced10e8804
comparison
equal deleted inserted replaced
67:f6334be47118 68:561a7518be6b
1 /* Generate from machine description the strings for each enum.
2 Copyright (C) 2010 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
19
20 #include "bconfig.h"
21 #include "system.h"
22 #include "coretypes.h"
23 #include "errors.h"
24 #include "read-md.h"
25
26 /* Called via traverse_enum_types. Emit an enum definition for
27 enum_type *SLOT. */
28
29 static int
30 print_enum_type (void **slot, void *info ATTRIBUTE_UNUSED)
31 {
32 struct enum_type *def;
33 struct enum_value *value;
34
35 def = (struct enum_type *) *slot;
36 printf ("\nconst char *const %s_strings[] = {", def->name);
37 for (value = def->values; value; value = value->next)
38 {
39 printf ("\n \"%s\"", value->def->name);
40 if (value->next)
41 putc (',', stdout);
42 }
43 printf ("\n};\n");
44 return 1;
45 }
46
47 int
48 main (int argc, char **argv)
49 {
50 progname = "genenums";
51
52 if (!read_md_files (argc, argv, NULL, NULL))
53 return (FATAL_EXIT_CODE);
54
55 puts ("/* Generated automatically by the program `genenums'");
56 puts (" from the machine description file. */\n");
57 puts ("#include \"config.h\"\n");
58 puts ("#include \"system.h\"\n");
59 puts ("#include \"insn-constants.h\"\n");
60
61 traverse_enum_types (print_enum_type, 0);
62
63 if (ferror (stdout) || fflush (stdout) || fclose (stdout))
64 return FATAL_EXIT_CODE;
65
66 return SUCCESS_EXIT_CODE;
67 }