OSDN Git Service

* config/m68k/m68k.c (m68k_rtx_costs): Adjust mul/div costs for
[pf3gnuchains/gcc-fork.git] / gcc / genconstants.c
1 /* Generate from machine description:
2    a series of #define statements, one for each constant named in
3    a (define_constants ...) pattern.
4
5    Copyright (C) 1987, 1991, 1995, 1998, 1999, 2000, 2001, 2003
6    Free Software Foundation, Inc.
7
8 This file is part of GCC.
9
10 GCC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
14
15 GCC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with GCC; see the file COPYING.  If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA.  */
24
25 /* This program does not use gensupport.c because it does not need to
26    look at insn patterns, only (define_constants), and we want to
27    minimize dependencies.  */
28
29 #include "bconfig.h"
30 #include "system.h"
31 #include "coretypes.h"
32 #include "tm.h"
33 #include "rtl.h"
34 #include "errors.h"
35 #include "gensupport.h"
36
37 static int print_md_constant (void **, void *);
38
39 /* Called via traverse_md_constants; emit a #define for
40    the current constant definition.  */
41
42 static int
43 print_md_constant (void **slot, void *info)
44 {
45   struct md_constant *def = *slot;
46   FILE *file = info;
47
48   fprintf (file, "#define %s %s\n", def->name, def->value);
49   return 1;
50 }
51
52 int
53 main (int argc, char **argv)
54 {
55   int dummy1, dummy2;
56   rtx desc;
57
58   progname = "genconstants";
59
60   if (argc <= 1)
61     fatal ("no input file name");
62
63   if (init_md_reader (argv[1]) != SUCCESS_EXIT_CODE)
64     return (FATAL_EXIT_CODE);
65
66   /* Scan and discard the entire file.  This has the side effect
67      of loading up the constants table that we wish to scan.  */
68   do
69     desc = read_md_rtx (&dummy1, &dummy2);
70   while (desc);
71
72   puts ("/* Generated automatically by the program `genconstants'");
73   puts ("   from the machine description file `md'.  */\n");
74   puts ("#ifndef GCC_INSN_CONSTANTS_H");
75   puts ("#define GCC_INSN_CONSTANTS_H\n");
76
77   traverse_md_constants (print_md_constant, stdout);
78
79   puts ("\n#endif /* GCC_INSN_CONSTANTS_H */");
80
81   if (ferror (stdout) || fflush (stdout) || fclose (stdout))
82     return FATAL_EXIT_CODE;
83
84   return SUCCESS_EXIT_CODE;
85 }
86