comparison gcc/gengenrtl.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Generate code to allocate RTL structures. 1 /* Generate code to allocate RTL structures.
2 Copyright (C) 1997-2018 Free Software Foundation, Inc. 2 Copyright (C) 1997-2020 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 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
7 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
229 printf (", (ARG%d)", i++); 229 printf (", (ARG%d)", i++);
230 230
231 puts (")"); 231 puts (")");
232 } 232 }
233 233
234 /* Generate the code for the function to generate RTL whose 234 /* Generate the code for functions to generate RTL whose format is FORMAT. */
235 format is FORMAT. */
236 235
237 static void 236 static void
238 gendef (const char *format) 237 gendef (const char *format)
239 { 238 {
240 const char *p; 239 const char *p;
241 int i, j; 240 int i, j;
242 241
243 /* Start by writing the definition of the function name and the types 242 /* Write the definition of the init function name and the types
244 of the arguments. */ 243 of the arguments. */
245 244
246 printf ("static inline rtx\ngen_rtx_fmt_%s_stat (RTX_CODE code, machine_mode mode", format); 245 puts ("static inline rtx");
246 printf ("init_rtx_fmt_%s (rtx rt, machine_mode mode", format);
247 for (p = format, i = 0; *p != 0; p++) 247 for (p = format, i = 0; *p != 0; p++)
248 if (*p != '0') 248 if (*p != '0')
249 printf (",\n\t%sarg%d", type_from_format (*p), i++); 249 printf (",\n\t%sarg%d", type_from_format (*p), i++);
250 250 puts (")");
251 puts (" MEM_STAT_DECL)"); 251
252 252 /* Now write out the body of the init function itself. */
253 /* Now write out the body of the function itself, which allocates
254 the memory and initializes it. */
255 puts ("{"); 253 puts ("{");
256 puts (" rtx rt;");
257 puts (" rt = rtx_alloc (code PASS_MEM_STAT);\n");
258
259 puts (" PUT_MODE_RAW (rt, mode);"); 254 puts (" PUT_MODE_RAW (rt, mode);");
260 255
261 for (p = format, i = j = 0; *p ; ++p, ++i) 256 for (p = format, i = j = 0; *p ; ++p, ++i)
262 if (*p == '0') 257 if (*p == '0')
263 printf (" X0EXP (rt, %d) = NULL_RTX;\n", i); 258 printf (" X0EXP (rt, %d) = NULL_RTX;\n", i);
264 else if (*p == 'p') 259 else if (*p == 'p')
265 printf (" SUBREG_BYTE (rt) = arg%d;\n", j++); 260 printf (" SUBREG_BYTE (rt) = arg%d;\n", j++);
266 else 261 else
267 printf (" %s (rt, %d) = arg%d;\n", accessor_from_format (*p), i, j++); 262 printf (" %s (rt, %d) = arg%d;\n", accessor_from_format (*p), i, j++);
268 263
269 puts ("\n return rt;\n}\n"); 264 puts (" return rt;\n}\n");
265
266 /* Write the definition of the gen function name and the types
267 of the arguments. */
268
269 puts ("static inline rtx");
270 printf ("gen_rtx_fmt_%s_stat (RTX_CODE code, machine_mode mode", format);
271 for (p = format, i = 0; *p != 0; p++)
272 if (*p != '0')
273 printf (",\n\t%sarg%d", type_from_format (*p), i++);
274 puts (" MEM_STAT_DECL)");
275
276 /* Now write out the body of the function itself, which allocates
277 the memory and initializes it. */
278 puts ("{");
279 puts (" rtx rt;\n");
280
281 puts (" rt = rtx_alloc (code PASS_MEM_STAT);");
282 printf (" return init_rtx_fmt_%s (rt, mode", format);
283 for (p = format, i = 0; *p != 0; p++)
284 if (*p != '0')
285 printf (", arg%d", i++);
286 puts (");\n}\n");
287
288 /* Write the definition of gen macro. */
289
270 printf ("#define gen_rtx_fmt_%s(c, m", format); 290 printf ("#define gen_rtx_fmt_%s(c, m", format);
271 for (p = format, i = 0; *p != 0; p++) 291 for (p = format, i = 0; *p != 0; p++)
272 if (*p != '0') 292 if (*p != '0')
273 printf (", p%i",i++); 293 printf (", arg%d", i++);
274 printf (")\\\n gen_rtx_fmt_%s_stat (c, m", format); 294 printf (") \\\n gen_rtx_fmt_%s_stat ((c), (m)", format);
275 for (p = format, i = 0; *p != 0; p++) 295 for (p = format, i = 0; *p != 0; p++)
276 if (*p != '0') 296 if (*p != '0')
277 printf (", p%i",i++); 297 printf (", (arg%d)", i++);
278 printf (" MEM_STAT_INFO)\n\n"); 298 printf (" MEM_STAT_INFO)\n\n");
299
300 /* Write the definition of alloca macro. */
301
302 printf ("#define alloca_rtx_fmt_%s(c, m", format);
303 for (p = format, i = 0; *p != 0; p++)
304 if (*p != '0')
305 printf (", arg%d", i++);
306 printf (") \\\n init_rtx_fmt_%s (rtx_alloca ((c)), (m)", format);
307 for (p = format, i = 0; *p != 0; p++)
308 if (*p != '0')
309 printf (", (arg%d)", i++);
310 printf (")\n\n");
279 } 311 }
280 312
281 /* Generate the documentation header for files we write. */ 313 /* Generate the documentation header for files we write. */
282 314
283 static void 315 static void