diff options
author | Takayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp> | 2023-01-27 12:17:33 +0900 |
---|---|---|
committer | Max Filippov <jcmvbkbc@gmail.com> | 2023-02-23 14:31:39 -0800 |
commit | 33e4559305e6f1adaa1b2b59f645d54fd98e5bbe (patch) | |
tree | 9fcc90b296dfcd754ee999d384eb85aadbcead7b /gcc/doc/cpp.texi | |
parent | 7423f5b56ad436f51ac1b9defb954e2bdc5b06ab (diff) | |
download | gcc-33e4559305e6f1adaa1b2b59f645d54fd98e5bbe.zip gcc-33e4559305e6f1adaa1b2b59f645d54fd98e5bbe.tar.gz gcc-33e4559305e6f1adaa1b2b59f645d54fd98e5bbe.tar.bz2 |
xtensa: Eliminate the use of callee-saved register that saves and restores only once
In the case of the CALL0 ABI, values that must be retained before and
after function calls are placed in the callee-saved registers (A12
through A15) and referenced later. However, it is often the case that
the save and the reference are each only once and a simple register-
register move (with two exceptions; i. the register saved to/restored
from is the stack pointer, ii. the function needs an additional stack
pointer adjustment to grow the stack).
e.g. in the following example, if there are no other occurrences of
register A14:
;; before
; prologue {
...
s32i.n a14, sp, 16
... ;; no frame pointer needed
;; no additional stack growth
; } prologue
...
mov.n a14, a6 ;; A6 is not SP
...
call0 foo
...
mov.n a8, a14 ;; A8 is not SP
...
; epilogue {
...
l32i.n a14, sp, 16
...
; } epilogue
It can be possible like this:
;; after
; prologue {
...
(no save needed)
...
; } prologue
...
s32i.n a6, sp, 16 ;; replaced with A14's slot
...
call0 foo
...
l32i.n a8, sp, 16 ;; through SP
...
; epilogue {
...
(no restoration needed)
...
; } epilogue
This patch adds the abovementioned logic to the function prologue/epilogue
RTL expander code.
gcc/ChangeLog:
* config/xtensa/xtensa.cc (machine_function): Add new member
'eliminated_callee_saved_bmp'.
(xtensa_can_eliminate_callee_saved_reg_p): New function to
determine whether the register can be eliminated or not.
(xtensa_expand_prologue): Add invoking the above function and
elimination the use of callee-saved register by using its stack
slot through the stack pointer (or the frame pointer if needed)
directly.
(xtensa_expand_prologue): Modify to not emit register restoration
insn from its stack slot if the register is already eliminated.
gcc/testsuite/ChangeLog:
* gcc.target/xtensa/elim_callee_saved.c: New.
Diffstat (limited to 'gcc/doc/cpp.texi')
0 files changed, 0 insertions, 0 deletions