]>
Commit | Line | Data |
---|---|---|
1b0c37d7 ZW |
1 | /* Generate from machine description: |
2 | a series of #define statements, one for each constant named in | |
3 | a (define_constants ...) pattern. | |
4 | ||
9dcd6f09 NC |
5 | Copyright (C) 1987, 1991, 1995, 1998, 1999, 2000, 2001, 2003, 2004, |
6 | 2007 Free Software Foundation, Inc. | |
1b0c37d7 | 7 | |
40803cd5 | 8 | This file is part of GCC. |
1b0c37d7 | 9 | |
40803cd5 | 10 | GCC is free software; you can redistribute it and/or modify |
1b0c37d7 | 11 | it under the terms of the GNU General Public License as published by |
9dcd6f09 | 12 | the Free Software Foundation; either version 3, or (at your option) |
1b0c37d7 ZW |
13 | any later version. |
14 | ||
40803cd5 | 15 | GCC is distributed in the hope that it will be useful, |
1b0c37d7 ZW |
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 | |
9dcd6f09 NC |
21 | along with GCC; see the file COPYING3. If not see |
22 | <http://www.gnu.org/licenses/>. */ | |
1b0c37d7 ZW |
23 | |
24 | /* This program does not use gensupport.c because it does not need to | |
25 | look at insn patterns, only (define_constants), and we want to | |
26 | minimize dependencies. */ | |
27 | ||
4977bab6 | 28 | #include "bconfig.h" |
1b0c37d7 | 29 | #include "system.h" |
4977bab6 ZW |
30 | #include "coretypes.h" |
31 | #include "tm.h" | |
1b0c37d7 ZW |
32 | #include "rtl.h" |
33 | #include "errors.h" | |
34 | #include "gensupport.h" | |
35 | ||
1b0c37d7 ZW |
36 | /* Called via traverse_md_constants; emit a #define for |
37 | the current constant definition. */ | |
38 | ||
39 | static int | |
3d7aafde | 40 | print_md_constant (void **slot, void *info) |
1b0c37d7 | 41 | { |
28dab132 BI |
42 | struct md_constant *def = (struct md_constant *) *slot; |
43 | FILE *file = (FILE *) info; | |
1b0c37d7 ZW |
44 | |
45 | fprintf (file, "#define %s %s\n", def->name, def->value); | |
46 | return 1; | |
47 | } | |
48 | ||
49 | int | |
3d7aafde | 50 | main (int argc, char **argv) |
1b0c37d7 | 51 | { |
1b0c37d7 ZW |
52 | progname = "genconstants"; |
53 | ||
f9942f4e | 54 | if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) |
1b0c37d7 ZW |
55 | return (FATAL_EXIT_CODE); |
56 | ||
f9942f4e ZW |
57 | /* Initializing the MD reader has the side effect of loading up |
58 | the constants table that we wish to scan. */ | |
1b0c37d7 ZW |
59 | |
60 | puts ("/* Generated automatically by the program `genconstants'"); | |
61 | puts (" from the machine description file `md'. */\n"); | |
62 | puts ("#ifndef GCC_INSN_CONSTANTS_H"); | |
63 | puts ("#define GCC_INSN_CONSTANTS_H\n"); | |
64 | ||
65 | traverse_md_constants (print_md_constant, stdout); | |
66 | ||
67 | puts ("\n#endif /* GCC_INSN_CONSTANTS_H */"); | |
68 | ||
69 | if (ferror (stdout) || fflush (stdout) || fclose (stdout)) | |
70 | return FATAL_EXIT_CODE; | |
71 | ||
72 | return SUCCESS_EXIT_CODE; | |
73 | } |