Skip to content

Commit 44fc9fc

Browse files
ethycS0kito-cheng
authored andcommitted
newlib: riscv: Add Zicfilp lpads to asm functions
Adds `lpad 0` instructions, guarded by `#if __riscv_landing_pad`, to the RISC-V assembly memory, setjmp and string functions. Signed-off-by: Arjun Salunkhe <arjun.salunkhe@proton.me>
1 parent 61360fd commit 44fc9fc

5 files changed

Lines changed: 22 additions & 0 deletions

File tree

newlib/libc/machine/riscv/memcpy-asm.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
.global memcpy
1515
.type memcpy, @function
1616
memcpy:
17+
#if __riscv_landing_pad
18+
lpad 0
19+
#endif
20+
1721
mv a3, a0
1822
beqz a2, 2f
1923

newlib/libc/machine/riscv/memmove-asm.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
.global memmove
1515
.type memmove, @function
1616
memmove:
17+
#if __riscv_landing_pad
18+
lpad 0
19+
#endif
20+
1721
beqz a2, .Ldone /* in case there are 0 bytes to be copied, return immediately */
1822

1923
mv a4, a0 /* copy the destination address over to a4, since memmove should return that address in a0 at the end */

newlib/libc/machine/riscv/memset.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050

5151

5252
memset:
53+
#if __riscv_landing_pad
54+
lpad 0
55+
#endif
56+
5357
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
5458
mv a3, a0
5559
beqz a2, .Ldone

newlib/libc/machine/riscv/setjmp.S

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
.globl setjmp
1616
.type setjmp, @function
1717
setjmp:
18+
#if __riscv_landing_pad
19+
lpad 0
20+
#endif
1821
REG_S ra, 0*SZREG(a0)
1922
#if __riscv_xlen == 32 && (__riscv_zilsd) && (__riscv_misaligned_fast)
2023
sd s0, 1*SZREG(a0)
@@ -70,6 +73,9 @@ setjmp:
7073
.globl longjmp
7174
.type longjmp, @function
7275
longjmp:
76+
#if __riscv_landing_pad
77+
lpad 0
78+
#endif
7379
REG_L ra, 0*SZREG(a0)
7480
#if __riscv_xlen == 32 && (__riscv_zilsd) && (__riscv_misaligned_fast)
7581
ld s0, 1*SZREG(a0)

newlib/libc/machine/riscv/strcmp.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
.globl strcmp
1616
.type strcmp, @function
1717
strcmp:
18+
#if __riscv_landing_pad
19+
lpad 0
20+
#endif
21+
1822
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
1923
.Lcompare:
2024
lbu a2, 0(a0)

0 commit comments

Comments
 (0)