Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RISCV] Support rv{32, 64}e in the compiler builtins #88252

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions compiler-rt/lib/builtins/riscv/restore.S
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#if __riscv_xlen == 32

#ifndef __riscv_32e

.globl __riscv_restore_12
.type __riscv_restore_12,@function
__riscv_restore_12:
Expand Down Expand Up @@ -86,8 +88,29 @@ __riscv_restore_0:
addi sp, sp, 16
ret

#else

.globl __riscv_restore_2
.type __riscv_restore_2,@function
.globl __riscv_restore_1
.type __riscv_restore_1,@function
.globl __riscv_restore_0
.type __riscv_restore_0,@function
__riscv_restore_2:
__riscv_restore_1:
__riscv_restore_0:
lw s1, 0(sp)
lw s0, 4(sp)
lw ra, 8(sp)
addi sp, sp, 12
ret

#endif

#elif __riscv_xlen == 64

#ifndef __riscv_64e

.globl __riscv_restore_12
.type __riscv_restore_12,@function
__riscv_restore_12:
Expand Down Expand Up @@ -161,6 +184,25 @@ __riscv_restore_0:
addi sp, sp, 16
ret

#else

.globl __riscv_restore_2
.type __riscv_restore_2,@function
.globl __riscv_restore_1
.type __riscv_restore_1,@function
.globl __riscv_restore_0
.type __riscv_restore_0,@function
__riscv_restore_2:
__riscv_restore_1:
__riscv_restore_0:
ld s1, 0(sp)
ld s0, 8(sp)
ld ra, 16(sp)
addi sp, sp, 24
ret

#endif

#else
# error "xlen must be 32 or 64 for save-restore implementation
#endif
42 changes: 42 additions & 0 deletions compiler-rt/lib/builtins/riscv/save.S
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#if __riscv_xlen == 32

#ifndef __riscv_32e

.globl __riscv_save_12
.type __riscv_save_12,@function
__riscv_save_12:
Expand Down Expand Up @@ -92,8 +94,29 @@ __riscv_save_0:
sw ra, 12(sp)
jr t0

#else

.globl __riscv_save_2
.type __riscv_save_2,@function
.globl __riscv_save_1
.type __riscv_save_1,@function
.globl __riscv_save_0
.type __riscv_save_0,@function
__riscv_save_2:
__riscv_save_1:
__riscv_save_0:
addi sp, sp, -12
sw s1, 0(sp)
sw s0, 4(sp)
sw ra, 8(sp)
jr t0

#endif

#elif __riscv_xlen == 64

#ifndef __riscv_64e

.globl __riscv_save_12
.type __riscv_save_12,@function
__riscv_save_12:
Expand Down Expand Up @@ -181,6 +204,25 @@ __riscv_save_0:
sd ra, 8(sp)
jr t0

#else

.globl __riscv_save_2
.type __riscv_save_2,@function
.globl __riscv_save_1
.type __riscv_save_1,@function
.globl __riscv_save_0
.type __riscv_save_0,@function
__riscv_save_2:
__riscv_save_1:
__riscv_save_0:
addi sp, sp, -24
sd s1, 0(sp)
sd s0, 8(sp)
sd ra, 16(sp)
jr t0

#endif

#else
# error "xlen must be 32 or 64 for save-restore implementation
#endif
Loading