History

Simplify RV64 function epilogue

Previous sp can be computed based from only frame pointer and short offset. ra and s0 can be restored from stack with constant fp offset.

Aleksi Hannula committed 11 months ago

Commit e7be7b11 parent 33273271 file · +6 −10Browse files

Unified · Split

riscv64-gen.c+6−10
@@ -911,18 +911,14 @@ ST_FUNC void gfunc_epilog(void) · 910 unmodified lines
911 loc = (loc - num_va_regs * 8);911 loc = (loc - num_va_regs * 8);
912 d = v = (-loc + 15) & -16;912 d = v = (-loc + 15) & -16;
913 913
914 if (v >= (1 << 11)) {914 EI(0x13, 0, 2, 8, num_va_regs * 8); // addi sp, s0, num_va_regs*8
915 d = 16;915 EI(0x03, 3, 1, 8, -8); // ld ra, -8(s0)
916 o(0x37 | (5 << 7) | UPPER(v-16)); //lui t0, upper(v)916 EI(0x03, 3, 8, 8, -16); // ld s0, -16(s0)
917 EI(0x13, 0, 5, 5, SIGN11(v-16)); // addi t0, t0, lo(v)917 EI(0x67, 0, 0, 1, 0); // jalr x0, 0(x1), aka ret
918 ER(0x33, 0, 2, 2, 5, 0); // add sp, sp, t0918
919 }
920 EI(0x03, 3, 1, 2, d - 8 - num_va_regs * 8); // ld ra, v-8(sp)
921 EI(0x03, 3, 8, 2, d - 16 - num_va_regs * 8); // ld s0, v-16(sp)
922 EI(0x13, 0, 2, 2, d); // addi sp, sp, v
923 EI(0x67, 0, 0, 1, 0); // jalr x0, 0(x1), aka ret
924 large_ofs_ind = ind;919 large_ofs_ind = ind;
925 if (v >= (1 << 11)) {920 if (v >= (1 << 11)) {
921 d = 16;
926 EI(0x13, 0, 8, 2, d - num_va_regs * 8); // addi s0, sp, d922 EI(0x13, 0, 8, 2, d - num_va_regs * 8); // addi s0, sp, d
927 o(0x37 | (5 << 7) | UPPER(v-16)); //lui t0, upper(v)923 o(0x37 | (5 << 7) | UPPER(v-16)); //lui t0, upper(v)
928 EI(0x13, 0, 5, 5, SIGN11(v-16)); // addi t0, t0, lo(v)924 EI(0x13, 0, 5, 5, SIGN11(v-16)); // addi t0, t0, lo(v)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t