]>
Commit | Line | Data |
---|---|---|
88a00ef7 JM |
1 | /* Generate attribute information shared between driver and core |
2 | compilers (insn-attr-common.h) from machine description. Split out | |
3 | of genattr.c. | |
5624e564 | 4 | Copyright (C) 1991-2015 Free Software Foundation, Inc. |
88a00ef7 JM |
5 | |
6 | This file is part of GCC. | |
7 | ||
8 | GCC is free software; you can redistribute it and/or modify it under | |
9 | the terms of the GNU General Public License as published by the Free | |
10 | Software Foundation; either version 3, or (at your option) any later | |
11 | version. | |
12 | ||
13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GCC; see the file COPYING3. If not see | |
20 | <http://www.gnu.org/licenses/>. */ | |
21 | ||
22 | ||
23 | #include "bconfig.h" | |
24 | #include "system.h" | |
25 | #include "coretypes.h" | |
26 | #include "tm.h" | |
27 | #include "rtl.h" | |
28 | #include "errors.h" | |
29 | #include "read-md.h" | |
30 | #include "gensupport.h" | |
31 | ||
c344a866 JR |
32 | static void |
33 | write_upcase (const char *str) | |
34 | { | |
35 | for (; *str; str++) | |
c3284718 | 36 | putchar (TOUPPER (*str)); |
c344a866 JR |
37 | } |
38 | ||
39 | static void | |
40 | gen_attr (rtx attr) | |
41 | { | |
42 | const char *p, *tag; | |
43 | ||
44 | p = XSTR (attr, 1); | |
45 | if (*p != '\0') | |
46 | { | |
47 | printf ("enum attr_%s {", XSTR (attr, 0)); | |
48 | ||
49 | while ((tag = scan_comma_elt (&p)) != 0) | |
50 | { | |
51 | write_upcase (XSTR (attr, 0)); | |
52 | putchar ('_'); | |
53 | while (tag != p) | |
54 | putchar (TOUPPER (*tag++)); | |
55 | if (*p == ',') | |
56 | fputs (", ", stdout); | |
57 | } | |
58 | fputs ("};\n", stdout); | |
59 | } | |
60 | } | |
61 | ||
88a00ef7 JM |
62 | int |
63 | main (int argc, char **argv) | |
64 | { | |
65 | rtx desc; | |
66 | bool have_delay = false; | |
67 | bool have_sched = false; | |
68 | ||
69 | progname = "genattr-common"; | |
70 | ||
71 | if (!init_rtx_reader_args (argc, argv)) | |
72 | return (FATAL_EXIT_CODE); | |
73 | ||
74 | puts ("/* Generated automatically by the program `genattr-common'"); | |
75 | puts (" from the machine description file `md'. */\n"); | |
76 | puts ("#ifndef GCC_INSN_ATTR_COMMON_H"); | |
77 | puts ("#define GCC_INSN_ATTR_COMMON_H\n"); | |
78 | ||
79 | /* Read the machine description. */ | |
80 | ||
81 | while (1) | |
82 | { | |
83 | int line_no, insn_code_number; | |
84 | ||
85 | desc = read_md_rtx (&line_no, &insn_code_number); | |
86 | if (desc == NULL) | |
87 | break; | |
88 | ||
c344a866 JR |
89 | if (GET_CODE (desc) == DEFINE_ATTR) |
90 | gen_attr (desc); | |
91 | ||
88a00ef7 JM |
92 | if (GET_CODE (desc) == DEFINE_DELAY) |
93 | { | |
94 | if (!have_delay) | |
95 | { | |
96 | printf ("#define DELAY_SLOTS\n"); | |
97 | have_delay = true; | |
98 | } | |
99 | } | |
100 | else if (GET_CODE (desc) == DEFINE_INSN_RESERVATION) | |
101 | { | |
102 | if (!have_sched) | |
103 | { | |
104 | printf ("#define INSN_SCHEDULING\n"); | |
105 | have_sched = true; | |
106 | } | |
107 | } | |
108 | } | |
109 | puts ("\n#endif /* GCC_INSN_ATTR_COMMON_H */"); | |
110 | ||
111 | if (ferror (stdout) || fflush (stdout) || fclose (stdout)) | |
112 | return FATAL_EXIT_CODE; | |
113 | ||
114 | return SUCCESS_EXIT_CODE; | |
115 | } |