public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Fei Gao <gaofei@eswincomputing.com>, gcc-patches@gcc.gnu.org
Cc: kito.cheng@gmail.com, palmer@dabbelt.com
Subject: Re: [PATCH] RISC-V: decouple stack allocation for rv32e w/o save-restore.
Date: Fri, 28 Apr 2023 15:29:05 -0600	[thread overview]
Message-ID: <ccb30f76-b18b-f2ce-8b36-08d7fafa02ce@gmail.com> (raw)
In-Reply-To: <20230421100722.17288-1-gaofei@eswincomputing.com>



On 4/21/23 04:07, Fei Gao wrote:
> Currently in rv32e, stack allocation for GPR callee-saved registers is
> always 12 bytes w/o save-restore. Actually, for the case without save-restore,
> less stack memory can be reserved. This patch decouples stack allocation for
> rv32e w/o save-restore and makes riscv_compute_frame_info more readable.
> 
> output of testcase rv32e_stack.c
> before patch:
> 	addi	sp,sp,-16
> 	sw	ra,12(sp)
> 	call	getInt
> 	sw	a0,0(sp)
> 	lw	a0,0(sp)
> 	call	PrintInts
> 	lw	a5,0(sp)
> 	mv	a0,a5
> 	lw	ra,12(sp)
> 	addi	sp,sp,16
> 	jr	ra
> 
> after patch:
> 	addi	sp,sp,-8
> 	sw	ra,4(sp)
> 	call	getInt
> 	sw	a0,0(sp)
> 	lw	a0,0(sp)
> 	call	PrintInts
> 	lw	a5,0(sp)
> 	mv	a0,a5
> 	lw	ra,4(sp)
> 	addi	sp,sp,8
> 	jr	ra
> 
> gcc/ChangeLog:
> 
>          * config/riscv/riscv.cc (riscv_forbid_save_libcall): helper function for riscv_use_save_libcall.
>          (riscv_use_save_libcall): call riscv_forbid_save_libcall.
>          (riscv_compute_frame_info): restructure to decouple stack allocation for rv32e w/o save-restore.
> 
> gcc/testsuite/ChangeLog:
> 
>          * gcc.target/riscv/rv32e_stack.c: New test.
> ---
>   gcc/config/riscv/riscv.cc                    | 57 ++++++++++++--------
>   gcc/testsuite/gcc.target/riscv/rv32e_stack.c | 14 +++++
>   2 files changed, 49 insertions(+), 22 deletions(-)
>   create mode 100644 gcc/testsuite/gcc.target/riscv/rv32e_stack.c
> 
> diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
> index 5d2550871c7..6ccdfe96fe7 100644
> --- a/gcc/config/riscv/riscv.cc
> +++ b/gcc/config/riscv/riscv.cc
> @@ -4772,12 +4772,26 @@ riscv_save_reg_p (unsigned int regno)
>     return false;
>   }
>   
> +/* Determine whether to disable GPR save/restore routines.  */
> +static bool
> +riscv_forbid_save_libcall (void)
I would suggest something like this for the function comment:

/* Return TRUE if a libcall to save/restore GPRs should be
    avoided.  FALSE otherwise.  */

I would also change the name from "forbid" to "avoid".


With those changes I think this will be ready for the trunk.  So repost 
after those changes and I'll get it pushed into the trunk.

Thanks,
Jeff

      reply	other threads:[~2023-04-28 21:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21 10:07 Fei Gao
2023-04-28 21:29 ` Jeff Law [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ccb30f76-b18b-f2ce-8b36-08d7fafa02ce@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gaofei@eswincomputing.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kito.cheng@gmail.com \
    --cc=palmer@dabbelt.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).