Mercurial > hg > CbC > GCC_original
comparison gcc/gengenrtl.c @ 16:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
15:561a7518be6b | 16:04ced10e8804 |
---|---|
1 /* Generate code to allocate RTL structures. | 1 /* Generate code to allocate RTL structures. |
2 Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2007, 2010 | 2 Copyright (C) 1997-2017 Free Software Foundation, Inc. |
3 Free Software Foundation, Inc. | |
4 | 3 |
5 This file is part of GCC. | 4 This file is part of GCC. |
6 | 5 |
7 GCC is free software; you can redistribute it and/or modify it under | 6 GCC is free software; you can redistribute it and/or modify it under |
8 the terms of the GNU General Public License as published by the Free | 7 the terms of the GNU General Public License as published by the Free |
36 | 35 |
37 static const struct rtx_definition defs[] = | 36 static const struct rtx_definition defs[] = |
38 { | 37 { |
39 #include "rtl.def" /* rtl expressions are documented here */ | 38 #include "rtl.def" /* rtl expressions are documented here */ |
40 }; | 39 }; |
41 #define NUM_RTX_CODE ARRAY_SIZE(defs) | 40 #define NUM_RTX_CODE ARRAY_SIZE (defs) |
42 | 41 |
43 static const char *formats[NUM_RTX_CODE]; | 42 static const char *formats[NUM_RTX_CODE]; |
44 | 43 |
45 /* Decode a format letter into a C type string. */ | 44 /* Decode a format letter into a C type string. */ |
46 | 45 |
62 return "rtx "; | 61 return "rtx "; |
63 | 62 |
64 case 'E': | 63 case 'E': |
65 return "rtvec "; | 64 return "rtvec "; |
66 case 't': | 65 case 't': |
67 return "union tree_node *"; /* tree - typedef not available */ | 66 return "tree "; |
68 case 'B': | 67 case 'B': |
69 return "struct basic_block_def *"; /* basic block - typedef not available */ | 68 return "basic_block "; |
70 default: | 69 default: |
71 gcc_unreachable (); | 70 gcc_unreachable (); |
72 } | 71 } |
73 } | 72 } |
74 | 73 |
112 special_format (const char *fmt) | 111 special_format (const char *fmt) |
113 { | 112 { |
114 return (strchr (fmt, '*') != 0 | 113 return (strchr (fmt, '*') != 0 |
115 || strchr (fmt, 'V') != 0 | 114 || strchr (fmt, 'V') != 0 |
116 || strchr (fmt, 'S') != 0 | 115 || strchr (fmt, 'S') != 0 |
117 || strchr (fmt, 'n') != 0); | 116 || strchr (fmt, 'n') != 0 |
117 || strchr (fmt, 'r') != 0); | |
118 } | |
119 | |
120 /* Return true if CODE always has VOIDmode. */ | |
121 | |
122 static inline bool | |
123 always_void_p (int idx) | |
124 { | |
125 return strcmp (defs[idx].enumname, "SET") == 0; | |
118 } | 126 } |
119 | 127 |
120 /* Return nonzero if the RTL code given by index IDX is one that we should | 128 /* Return nonzero if the RTL code given by index IDX is one that we should |
121 generate a gen_rtx_raw_FOO macro for, not gen_rtx_FOO (because gen_rtx_FOO | 129 generate a gen_rtx_raw_FOO macro for, not gen_rtx_FOO (because gen_rtx_FOO |
122 is a wrapper in emit-rtl.c). */ | 130 is a wrapper in emit-rtl.c). */ |
123 | 131 |
124 static int | 132 static int |
125 special_rtx (int idx) | 133 special_rtx (int idx) |
126 { | 134 { |
127 return (strcmp (defs[idx].enumname, "CONST_INT") == 0 | 135 return (strcmp (defs[idx].enumname, "EXPR_LIST") == 0 |
136 || strcmp (defs[idx].enumname, "INSN_LIST") == 0 | |
137 || strcmp (defs[idx].enumname, "INSN") == 0 | |
138 || strcmp (defs[idx].enumname, "CONST_INT") == 0 | |
128 || strcmp (defs[idx].enumname, "REG") == 0 | 139 || strcmp (defs[idx].enumname, "REG") == 0 |
129 || strcmp (defs[idx].enumname, "SUBREG") == 0 | 140 || strcmp (defs[idx].enumname, "SUBREG") == 0 |
130 || strcmp (defs[idx].enumname, "MEM") == 0 | 141 || strcmp (defs[idx].enumname, "MEM") == 0 |
142 || strcmp (defs[idx].enumname, "PC") == 0 | |
143 || strcmp (defs[idx].enumname, "CC0") == 0 | |
144 || strcmp (defs[idx].enumname, "RETURN") == 0 | |
145 || strcmp (defs[idx].enumname, "SIMPLE_RETURN") == 0 | |
131 || strcmp (defs[idx].enumname, "CONST_VECTOR") == 0); | 146 || strcmp (defs[idx].enumname, "CONST_VECTOR") == 0); |
132 } | 147 } |
133 | 148 |
134 /* Return nonzero if the RTL code given by index IDX is one that we should | 149 /* Return nonzero if the RTL code given by index IDX is one that we should |
135 generate no macro for at all (because gen_rtx_FOO is never used or | 150 generate no macro for at all (because gen_rtx_FOO is never used or |
136 cannot have the obvious interface). */ | 151 cannot have the obvious interface). */ |
137 | 152 |
138 static int | 153 static int |
139 excluded_rtx (int idx) | 154 excluded_rtx (int idx) |
140 { | 155 { |
141 return ((strcmp (defs[idx].enumname, "CONST_DOUBLE") == 0) | 156 return (strcmp (defs[idx].enumname, "VAR_LOCATION") == 0 |
142 || (strcmp (defs[idx].enumname, "CONST_FIXED") == 0)); | 157 || strcmp (defs[idx].enumname, "CONST_DOUBLE") == 0 |
158 || strcmp (defs[idx].enumname, "CONST_WIDE_INT") == 0 | |
159 || strcmp (defs[idx].enumname, "CONST_FIXED") == 0); | |
143 } | 160 } |
144 | 161 |
145 /* Place a list of all format specifiers we use into the array FORMAT. */ | 162 /* Place a list of all format specifiers we use into the array FORMAT. */ |
146 | 163 |
147 static void | 164 static void |
171 | 188 |
172 static void | 189 static void |
173 genmacro (int idx) | 190 genmacro (int idx) |
174 { | 191 { |
175 const char *p; | 192 const char *p; |
193 const char *sep = ""; | |
176 int i; | 194 int i; |
177 | 195 |
178 /* We write a macro that defines gen_rtx_RTLCODE to be an equivalent to | 196 /* We write a macro that defines gen_rtx_RTLCODE to be an equivalent to |
179 gen_rtx_fmt_FORMAT where FORMAT is the RTX_FORMAT of RTLCODE. */ | 197 gen_rtx_fmt_FORMAT where FORMAT is the RTX_FORMAT of RTLCODE. */ |
180 | 198 |
181 if (excluded_rtx (idx)) | 199 if (excluded_rtx (idx)) |
182 /* Don't define a macro for this code. */ | 200 /* Don't define a macro for this code. */ |
183 return; | 201 return; |
184 | 202 |
185 printf ("#define gen_rtx_%s%s(MODE", | 203 bool has_mode_p = !always_void_p (idx); |
204 printf ("#define gen_rtx_%s%s(", | |
186 special_rtx (idx) ? "raw_" : "", defs[idx].enumname); | 205 special_rtx (idx) ? "raw_" : "", defs[idx].enumname); |
206 if (has_mode_p) | |
207 { | |
208 printf ("MODE"); | |
209 sep = ", "; | |
210 } | |
187 | 211 |
188 for (p = defs[idx].format, i = 0; *p != 0; p++) | 212 for (p = defs[idx].format, i = 0; *p != 0; p++) |
189 if (*p != '0') | 213 if (*p != '0') |
190 printf (", ARG%d", i++); | 214 { |
191 | 215 printf ("%sARG%d", sep, i++); |
192 printf (") \\\n gen_rtx_fmt_%s (%s, (MODE)", | 216 sep = ", "; |
193 defs[idx].format, defs[idx].enumname); | 217 } |
218 | |
219 printf (") \\\n gen_rtx_fmt_%s (%s, %s", | |
220 defs[idx].format, defs[idx].enumname, | |
221 has_mode_p ? "(MODE)" : "VOIDmode"); | |
194 | 222 |
195 for (p = defs[idx].format, i = 0; *p != 0; p++) | 223 for (p = defs[idx].format, i = 0; *p != 0; p++) |
196 if (*p != '0') | 224 if (*p != '0') |
197 printf (", (ARG%d)", i++); | 225 printf (", (ARG%d)", i++); |
198 | 226 |
209 int i, j; | 237 int i, j; |
210 | 238 |
211 /* Start by writing the definition of the function name and the types | 239 /* Start by writing the definition of the function name and the types |
212 of the arguments. */ | 240 of the arguments. */ |
213 | 241 |
214 printf ("static inline rtx\ngen_rtx_fmt_%s_stat (RTX_CODE code, enum machine_mode mode", format); | 242 printf ("static inline rtx\ngen_rtx_fmt_%s_stat (RTX_CODE code, machine_mode mode", format); |
215 for (p = format, i = 0; *p != 0; p++) | 243 for (p = format, i = 0; *p != 0; p++) |
216 if (*p != '0') | 244 if (*p != '0') |
217 printf (",\n\t%sarg%d", type_from_format (*p), i++); | 245 printf (",\n\t%sarg%d", type_from_format (*p), i++); |
218 | 246 |
219 puts (" MEM_STAT_DECL)"); | 247 puts (" MEM_STAT_DECL)"); |
220 | 248 |
221 /* Now write out the body of the function itself, which allocates | 249 /* Now write out the body of the function itself, which allocates |
222 the memory and initializes it. */ | 250 the memory and initializes it. */ |
223 puts ("{"); | 251 puts ("{"); |
224 puts (" rtx rt;"); | 252 puts (" rtx rt;"); |
225 puts (" rt = rtx_alloc_stat (code PASS_MEM_STAT);\n"); | 253 puts (" rt = rtx_alloc (code PASS_MEM_STAT);\n"); |
226 | 254 |
227 puts (" PUT_MODE (rt, mode);"); | 255 puts (" PUT_MODE_RAW (rt, mode);"); |
228 | 256 |
229 for (p = format, i = j = 0; *p ; ++p, ++i) | 257 for (p = format, i = j = 0; *p ; ++p, ++i) |
230 if (*p != '0') | 258 if (*p != '0') |
231 printf (" %s (rt, %d) = arg%d;\n", accessor_from_format (*p), i, j++); | 259 printf (" %s (rt, %d) = arg%d;\n", accessor_from_format (*p), i, j++); |
232 else | 260 else |