]>
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 | ||
5 | Copyright (C) 1987, 1991, 1995, 1998, | |
6 | 1999, 2000, 2001 Free Software Foundation, Inc. | |
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 ZW |
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 | ||
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 | |
40803cd5 | 21 | along with GCC; see the file COPYING. If not, write to |
1b0c37d7 ZW |
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 "hconfig.h" | |
30 | #include "system.h" | |
31 | #include "rtl.h" | |
32 | #include "errors.h" | |
33 | #include "gensupport.h" | |
34 | ||
35 | static int print_md_constant PARAMS ((void **, void *)); | |
36 | extern int main PARAMS ((int, char **)); | |
37 | ||
38 | /* Called via traverse_md_constants; emit a #define for | |
39 | the current constant definition. */ | |
40 | ||
41 | static int | |
42 | print_md_constant (slot, info) | |
43 | void **slot; | |
44 | void *info; | |
45 | { | |
46 | struct md_constant *def = *slot; | |
47 | FILE *file = info; | |
48 | ||
49 | fprintf (file, "#define %s %s\n", def->name, def->value); | |
50 | return 1; | |
51 | } | |
52 | ||
53 | int | |
54 | main (argc, argv) | |
55 | int argc; | |
56 | char **argv; | |
57 | { | |
58 | int dummy1, dummy2; | |
59 | rtx desc; | |
60 | ||
61 | progname = "genconstants"; | |
62 | ||
63 | if (argc <= 1) | |
1f978f5f | 64 | fatal ("no input file name"); |
1b0c37d7 ZW |
65 | |
66 | if (init_md_reader (argv[1]) != SUCCESS_EXIT_CODE) | |
67 | return (FATAL_EXIT_CODE); | |
68 | ||
69 | /* Scan and discard the entire file. This has the side effect | |
70 | of loading up the constants table that we wish to scan. */ | |
71 | do | |
72 | desc = read_md_rtx (&dummy1, &dummy2); | |
73 | while (desc); | |
74 | ||
75 | puts ("/* Generated automatically by the program `genconstants'"); | |
76 | puts (" from the machine description file `md'. */\n"); | |
77 | puts ("#ifndef GCC_INSN_CONSTANTS_H"); | |
78 | puts ("#define GCC_INSN_CONSTANTS_H\n"); | |
79 | ||
80 | traverse_md_constants (print_md_constant, stdout); | |
81 | ||
82 | puts ("\n#endif /* GCC_INSN_CONSTANTS_H */"); | |
83 | ||
84 | if (ferror (stdout) || fflush (stdout) || fclose (stdout)) | |
85 | return FATAL_EXIT_CODE; | |
86 | ||
87 | return SUCCESS_EXIT_CODE; | |
88 | } | |
89 |