Choosing registers for assembly snippets
Zixian Cai
zixian.cai at anu.edu.au
Tue Oct 4 11:59:57 UTC 2022
Hi all,
I’m just wondering what the best practices are in terms of choosing registers.
I was looking at the assembly code for tlab allocation (https://github.com/openjdk/jdk/blob/5a9cd33632862aa2249794902d4168a7fe143054/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp#L131) and noticed the following.
1. tmp1 register is invalid.
2. tmp2 register is valid but sometimes clashes with var_size_in_bytes, which requires the workaround here https://github.com/openjdk/jdk/blob/5a9cd33632862aa2249794902d4168a7fe143054/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp#L155
3. t0 is used as a temporary register despite not passed into the method as a temporary register https://github.com/openjdk/jdk/blob/5a9cd33632862aa2249794902d4168a7fe143054/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp#L149
I’d really appreciate if someone could shed insight on how these decisions are made so that I can avoid common pitfalls when writing assembly code. The only resource I found at the moment is the architecture description file https://github.com/openjdk/jdk/blob/5a9cd33632862aa2249794902d4168a7fe143054/src/hotspot/cpu/riscv/riscv.ad#L73 which suggests x5(t0)-x6(t1) can always be used as temporary registers.
Sincerely,
Zixian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/riscv-port-dev/attachments/20221004/11834530/attachment-0001.htm>
More information about the riscv-port-dev
mailing list