From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 131001 invoked by alias); 5 Sep 2019 11:11:01 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 130992 invoked by uid 89); 5 Sep 2019 11:11:01 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=FORMAT X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Sep 2019 11:10:59 +0000 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x85B7stR011485 for ; Thu, 5 Sep 2019 07:10:56 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2utxjhqbaw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 05 Sep 2019 07:10:55 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Sep 2019 12:10:53 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 5 Sep 2019 12:10:50 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x85BAmDq55050468 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 5 Sep 2019 11:10:48 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 83FE4A405B; Thu, 5 Sep 2019 11:10:48 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 38CC4A4040; Thu, 5 Sep 2019 11:10:48 +0000 (GMT) Received: from white.boeblingen.de.ibm.com (unknown [9.152.97.226]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 5 Sep 2019 11:10:48 +0000 (GMT) From: Ilya Leoshkevich To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com, richard.sandiford@arm.com, segher@kernel.crashing.org, joseph@codesourcery.com, krebbel@linux.ibm.com, rdapp@linux.ibm.com, Ilya Leoshkevich Subject: [PATCH v3 2/9] Introduce rtx_alloca, alloca_raw_REG and alloca_rtx_fmt_* Date: Thu, 05 Sep 2019 11:11:00 -0000 In-Reply-To: <20190905111019.8951-1-iii@linux.ibm.com> References: <20190905111019.8951-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit x-cbid: 19090511-0016-0000-0000-000002A7068C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19090511-0017-0000-0000-00003307793C Message-Id: <20190905111019.8951-3-iii@linux.ibm.com> X-IsSubscribed: yes X-SW-Source: 2019-09/txt/msg00272.txt.bz2 One of the next patches in series needs to frequently pass short-lived fake rtxes to the back-end in order to test its capabilities. In order to reduce the load on GC, it is beneficial to allocate these rtxes on stack. Provide the macro counterparts of gen_* functions required by the next patch in series. gcc/ChangeLog: 2019-08-27 Ilya Leoshkevich PR target/77918 * emit-rtl.c (gen_raw_REG): Use init_raw_REG. (init_raw_REG): New function. * 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. --- gcc/emit-rtl.c | 15 +++++++++--- gcc/gengenrtl.c | 64 +++++++++++++++++++++++++++++++++++++------------ gcc/rtl.c | 7 +----- gcc/rtl.h | 12 ++++++++++ 4 files changed, 74 insertions(+), 24 deletions(-) diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index a667cdab94e..ecfa3735bba 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -466,20 +466,29 @@ set_mode_and_regno (rtx x, machine_mode mode, unsigned int regno) set_regno_raw (x, regno, nregs); } -/* Generate a new REG rtx. Make sure ORIGINAL_REGNO is set properly, and +/* Initialize a REG rtx. Make sure ORIGINAL_REGNO is set properly, and don't attempt to share with the various global pieces of rtl (such as frame_pointer_rtx). */ rtx -gen_raw_REG (machine_mode mode, unsigned int regno) +init_raw_REG (rtx x, machine_mode mode, unsigned int regno) { - rtx x = rtx_alloc (REG MEM_STAT_INFO); set_mode_and_regno (x, mode, regno); REG_ATTRS (x) = NULL; ORIGINAL_REGNO (x) = regno; return x; } +/* Generate a new REG rtx. */ + +rtx +gen_raw_REG (machine_mode mode, unsigned int regno) +{ + rtx x = rtx_alloc (REG MEM_STAT_INFO); + init_raw_REG (x, mode, regno); + return x; +} + /* There are some RTL codes that require special attention; the generation functions do the raw handling. If you add to this list, modify special_rtx in gengenrtl.c as well. */ diff --git a/gcc/gengenrtl.c b/gcc/gengenrtl.c index 5c78fabfb50..cd314a68a83 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,55 @@ 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 (" init_rtx_fmt_%s (rt, mode", format); + for (p = format, i = 0; *p != 0; p++) + if (*p != '0') + printf (", arg%d", i++); + puts (");\n"); + + puts (" return rt;\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. */ diff --git a/gcc/rtl.c b/gcc/rtl.c index d7b8e9877c3..0be52d38d93 100644 --- a/gcc/rtl.c +++ b/gcc/rtl.c @@ -219,12 +219,7 @@ rtx_alloc_stat_v (RTX_CODE code MEM_STAT_DECL, int extra) rtx rt = ggc_alloc_rtx_def_stat (RTX_CODE_SIZE (code) + extra PASS_MEM_STAT); - /* We want to clear everything up to the FLD array. Normally, this - is one int, but we don't want to assume that and it isn't very - portable anyway; this is. */ - - memset (rt, 0, RTX_HDR_SIZE); - PUT_CODE (rt, code); + rtx_init (rt, code); if (GATHER_STATISTICS) { diff --git a/gcc/rtl.h b/gcc/rtl.h index efb9b3ce40d..cf1547196f2 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -2933,6 +2933,15 @@ extern HOST_WIDE_INT get_stack_check_protect (void); /* In rtl.c */ extern rtx rtx_alloc (RTX_CODE CXX_MEM_STAT_INFO); +inline rtx +rtx_init (rtx rt, RTX_CODE code) +{ + memset (rt, 0, RTX_HDR_SIZE); + PUT_CODE (rt, code); + return rt; +} +#define rtx_alloca(code) \ + rtx_init ((rtx) alloca (RTX_CODE_SIZE ((code))), (code)) extern rtx rtx_alloc_stat_v (RTX_CODE MEM_STAT_DECL, int); #define rtx_alloc_v(c, SZ) rtx_alloc_stat_v (c MEM_STAT_INFO, SZ) #define const_wide_int_alloc(NWORDS) \ @@ -3797,7 +3806,10 @@ gen_rtx_INSN (machine_mode mode, rtx_insn *prev_insn, rtx_insn *next_insn, extern rtx gen_rtx_CONST_INT (machine_mode, HOST_WIDE_INT); extern rtx gen_rtx_CONST_VECTOR (machine_mode, rtvec); extern void set_mode_and_regno (rtx, machine_mode, unsigned int); +extern rtx init_raw_REG (rtx, machine_mode, unsigned int); extern rtx gen_raw_REG (machine_mode, unsigned int); +#define alloca_raw_REG(mode, regno) \ + init_raw_REG (rtx_alloca (REG), (mode), (regno)) extern rtx gen_rtx_REG (machine_mode, unsigned int); extern rtx gen_rtx_SUBREG (machine_mode, rtx, poly_uint64); extern rtx gen_rtx_MEM (machine_mode, rtx); -- 2.21.0