Skip to content

Commit 8bb7af5

Browse files
authored
i#3544: RV64: Port test common.getretaddr to RV64 (#7169)
Port assembly in common/getretaddr.c to riscv64 and implements tailcall_with_retaddr(). Issue: #3544
1 parent 3a84980 commit 8bb7af5

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

suite/tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6426,6 +6426,7 @@ if (RISCV64)
64266426
code_api|client.unregister
64276427
code_api|common.broadfun
64286428
code_api|common.hello
6429+
code_api|common.getretaddr
64296430
code_api|libutil.drconfig_test
64306431
code_api|libutil.frontend_test
64316432
# TODO i#3544: code_api|linux.eintr failed under QEMU

suite/tests/common/getretaddr.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,11 @@ GLOBAL_LABEL(FUNCNAME:)
113113
ldr x30, [sp], #16
114114
ret
115115
# elif defined(RISCV64)
116-
/* TODO i#3544: Port tests to RISC-V 64 */
117-
ret
116+
mv t0, ra
117+
call next_instr
118+
next_instr:
119+
mv a0, ra
120+
jr t0
118121
# else
119122
# error NYI
120123
# endif
@@ -134,7 +137,7 @@ GLOBAL_LABEL(FUNCNAME:)
134137
ldr x0, [x29, #8]
135138
ret
136139
# elif defined(RISCV64)
137-
/* TODO i#3544: Port tests to RISC-V 64 */
140+
ld a0, -8(fp)
138141
ret
139142
# else
140143
# error NYI

suite/tests/tools.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,9 @@ GLOBAL_LABEL(FUNCNAME:)
805805
mov x0, x30 /* Replace first argument with return address. */
806806
br x9 /* Tailcall to function pointer. */
807807
#elif defined(RISCV64)
808-
/* TODO i#3544: Port tests to RISC-V64 */
809-
ret
808+
mv t0, a0 /* Move function pointer to scratch register. */
809+
mv a0, ra /* Replace first argument with return address. */
810+
jr t0 /* Tailcall to function pointer. */
810811
#else
811812
# error NYI
812813
#endif

0 commit comments

Comments
 (0)