With -mgeneral-regs-only, all arguments are passed in GPRs, so we should use gr_top/gr_offs in va_list even for floating-point types.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
It seems that the intention of -mgeneral-regs-only is to prevent FP and SIMD register use.
aarch64-linux-gnu-gcc has such an error
error: ‘-mgeneral-regs-only’ is incompatible with the use of floating-point types
Clang doesn't reject FP in Sema yet, but I think changing CodeGen is incorrect.
Currently using Clang with -mgeneral-regs-only generates perfectly fine soft-float AArch64, with the except of the va_arg() implementation which is fixed here. In fact Rust even has a aarch64-unknown-none-softfloat which relies on this behavior in LLVM. I believe this behavior is *more* useful than GCC's which simply rejects float/double types, and it makes sense to keep it and fix it.
With -mgeneral-regs-only, all arguments are passed in GPRs, so we should use gr_top/gr_offs in va_list even for floating-point types.
I don't believe that -mgeneral-regs-only was intended to define an ABI passing floats in GPRs for AArch64. If it has that is likely a mistake, I don't recall any such ABI being defined.
I fully agree that this likely wasn't intentional, but this is still very useful for code that can't use FP registers for whatever reason (e.g. kernels). Regarding the ABI, it doesn't need to be officially defined: it just needs to be compatible with other code compiled with -mgeneral-regs-only.