[libc-commits] [PATCH] D145584: [libc] Add support for setjmp and longjmp in riscv
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Mon Mar 13 21:51:44 PDT 2023
sivachandra added a comment.
I have left comments in `longjmp.cpp` but same questions apply for `setjmp.cpp` as well.
================
Comment at: libc/src/setjmp/longjmp.cpp:18
+#if defined(LIBC_TARGET_ARCH_IS_RISCV64)
+__attribute__((naked)) // Don't generate function epilogue and prologue
+#endif
----------------
Why is this required?
================
Comment at: libc/src/setjmp/longjmp.cpp:64
+#pragma GCC diagnostic ignored "-Wuninitialized"
+ LIBC_INLINE_ASM("ld %0, 0(%1)\n\t" : "=r"(ra) : "r"(a0) :);
+ LIBC_INLINE_ASM("ld %0, 8(%1)\n\t" : "=r"(s0) : "r"(a0) :);
----------------
Can't we directly reference `buf` instead of using these fixed offsets, much like how we do for x86_64 case?
================
Comment at: libc/src/setjmp/longjmp.cpp:109
+
+ LIBC_INLINE_ASM("seqz %0, %1" : "=r"(a0) : "r"(a1) :);
+ LIBC_INLINE_ASM("add %0, %0, %1" : "=r"(a0) : "r"(a1), "r"(a0) :);
----------------
Same here, can we read `val` instead of reading `a1`?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145584/new/
https://reviews.llvm.org/D145584
More information about the libc-commits
mailing list