aboutsummaryrefslogtreecommitdiff
path: root/gcc/gengenrtl.c
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2019-09-30 14:56:33 +0000
committerIlya Leoshkevich <iii@gcc.gnu.org>2019-09-30 14:56:33 +0000
commit20fa157e674d0175f8c2717683462cdaded4d5be (patch)
tree352896fb14df54a2a599b18e2707299ae6055830 /gcc/gengenrtl.c
parent9343bf99b5e36fa11b723aafa282fd5900a5e525 (diff)
downloadgcc-20fa157e674d0175f8c2717683462cdaded4d5be.zip
gcc-20fa157e674d0175f8c2717683462cdaded4d5be.tar.gz
gcc-20fa157e674d0175f8c2717683462cdaded4d5be.tar.bz2
Introduce rtx_alloca, alloca_raw_REG and alloca_rtx_fmt_*
When one passes short-lived fake rtxes to backends in order to test their capabilities, it might be beneficial to allocate these rtxes on stack in order to reduce the load on GC. Provide macro counterparts of some of the gen_* functions for that purpose. gcc/ChangeLog: 2019-09-30 Ilya Leoshkevich <iii@linux.ibm.com> * emit-rtl.c (init_raw_REG): New function. (gen_raw_REG): Use init_raw_REG. * gengenrtl.c (gendef): Emit init_* functions and alloca_* macros. * rtl.c (rtx_alloc_stat_v): Use rtx_init. * rtl.h (rtx_init): New function. (rtx_alloca): New function. (init_raw_REG): New function. (alloca_raw_REG): New macro. From-SVN: r276303
Diffstat (limited to 'gcc/gengenrtl.c')
-rw-r--r--gcc/gengenrtl.c62
1 files changed, 47 insertions, 15 deletions
diff --git a/gcc/gengenrtl.c b/gcc/gengenrtl.c
index 5c78fab..eebbc09 100644
--- a/gcc/gengenrtl.c
+++ b/gcc/gengenrtl.c
@@ -231,8 +231,7 @@ genmacro (int idx)
puts (")");
}
-/* Generate the code for the function to generate RTL whose
- format is FORMAT. */
+/* Generate the code for functions to generate RTL whose format is FORMAT. */
static void
gendef (const char *format)
@@ -240,22 +239,18 @@ gendef (const char *format)
const char *p;
int i, j;
- /* Start by writing the definition of the function name and the types
+ /* Write the definition of the init function name and the types
of the arguments. */
- printf ("static inline rtx\ngen_rtx_fmt_%s_stat (RTX_CODE code, machine_mode mode", format);
+ puts ("static inline rtx");
+ printf ("init_rtx_fmt_%s (rtx rt, machine_mode mode", format);
for (p = format, i = 0; *p != 0; p++)
if (*p != '0')
printf (",\n\t%sarg%d", type_from_format (*p), i++);
+ puts (")");
- puts (" MEM_STAT_DECL)");
-
- /* Now write out the body of the function itself, which allocates
- the memory and initializes it. */
+ /* Now write out the body of the init function itself. */
puts ("{");
- puts (" rtx rt;");
- puts (" rt = rtx_alloc (code PASS_MEM_STAT);\n");
-
puts (" PUT_MODE_RAW (rt, mode);");
for (p = format, i = j = 0; *p ; ++p, ++i)
@@ -266,16 +261,53 @@ gendef (const char *format)
else
printf (" %s (rt, %d) = arg%d;\n", accessor_from_format (*p), i, j++);
- puts ("\n return rt;\n}\n");
+ puts (" return rt;\n}\n");
+
+ /* Write the definition of the gen function name and the types
+ of the arguments. */
+
+ puts ("static inline rtx");
+ printf ("gen_rtx_fmt_%s_stat (RTX_CODE code, machine_mode mode", format);
+ for (p = format, i = 0; *p != 0; p++)
+ if (*p != '0')
+ printf (",\n\t%sarg%d", type_from_format (*p), i++);
+ puts (" MEM_STAT_DECL)");
+
+ /* Now write out the body of the function itself, which allocates
+ the memory and initializes it. */
+ puts ("{");
+ puts (" rtx rt;\n");
+
+ puts (" rt = rtx_alloc (code PASS_MEM_STAT);");
+ printf (" return init_rtx_fmt_%s (rt, mode", format);
+ for (p = format, i = 0; *p != 0; p++)
+ if (*p != '0')
+ printf (", arg%d", i++);
+ puts (");\n}\n");
+
+ /* Write the definition of gen macro. */
+
printf ("#define gen_rtx_fmt_%s(c, m", format);
for (p = format, i = 0; *p != 0; p++)
if (*p != '0')
- printf (", p%i",i++);
- printf (")\\\n gen_rtx_fmt_%s_stat (c, m", format);
+ printf (", arg%d", i++);
+ printf (") \\\n gen_rtx_fmt_%s_stat ((c), (m)", format);
for (p = format, i = 0; *p != 0; p++)
if (*p != '0')
- printf (", p%i",i++);
+ printf (", (arg%d)", i++);
printf (" MEM_STAT_INFO)\n\n");
+
+ /* Write the definition of alloca macro. */
+
+ printf ("#define alloca_rtx_fmt_%s(c, m", format);
+ for (p = format, i = 0; *p != 0; p++)
+ if (*p != '0')
+ printf (", arg%d", i++);
+ printf (") \\\n init_rtx_fmt_%s (rtx_alloca ((c)), (m)", format);
+ for (p = format, i = 0; *p != 0; p++)
+ if (*p != '0')
+ printf (", (arg%d)", i++);
+ printf (")\n\n");
}
/* Generate the documentation header for files we write. */