Skip to content
Snippets Groups Projects
Commit a5b2a3bf authored by Fei Gao's avatar Fei Gao Committed by Jeff Law
Browse files

RISC-V: decouple stack allocation for rv32e w/o save-restore

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_avoid_save_libcall): helper function
	for riscv_use_save_libcall.
	(riscv_use_save_libcall): call riscv_avoid_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.
parent 50205195
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment