Repository navigation
[Xtensa] Enable ESP32-S3 QR registers in inline asm (LLVM-608) - #145
Dominaezzz wants to merge 1 commit into
Conversation
|
Hi! I'm not Espressif, so take it with a grain of salt. So, there is a bit of a problem with unreserving the registers here. QRs are on the coprocessor. And the coprocessor is a little peculiar. This is partly documented on ESP-IDF and a (very good) explanation of its restrictions was mentioned here. Basically, if we enable them unconditionally, we can panic or incur big context switch costs. This is not to say it can't be done. We just have to be more surgical instead of letting the compiler take control everywhere. At a glance there seem to be some legalization issues. This would make vector ops without selection patterns legal, which would crash. Spill logic also might need some refinement. I've also been working on QRs for a while, before I got derailed myself with register scavenger. I was meaning to get SLP/Loop vectorization working, and it does - albeit with a very primitive TTI. For me it was mainly academic, just to learn the plumbing of LLVM. And Xtensa felt like a good place given its (relative) simplicity. Nice to see there is some actual interest. If you're interested, I think we could combine with your q constraints and it should fit seamlessly.(considering the limitations of course) I have to ask whether the Espressif team would be willing (or have capacity) to review, though. I meant to wait until we could sort out the scavenger PRs, but might as well ask now and save us the potential double work. |
1a1d4b3 to
b3460ae
Compare
Thanks for the link. I kinda had this at the back of my mind but didn't know others had thought of it.
I would be interested in saving us the double work. I'm am very new to LLVM here and I made heavy use of Codex do this.
I think I understand what you're saying here but don't know how to go about it.
Ah got it |
Description
The Xtensa backend defines the ESP32-S3 PIE instructions and QR registers, but keeps the QR registers reserved and unavailable to LLVM’s register allocator. This change enables the QR register class on ESP32-S3 and adds the
qinline-assembly constraint for 128-bit vectors with<16 x i8>,<8 x i16>, and<4 x i32>lanes.It also adds QR register copies, spill handling, and vector load/store lowering so vector values can move between memory and Q registers and remain usable under register pressure. The change is gated on ESP32-S3 operations, leaving other Xtensa targets unchanged.
This provides the LLVM backend support required by the Rust inline-assembly change.
Related
Testing
Configured a fresh Release build with the Xtensa target and built
llcandFileCheck. Ran the newqr-inline-asm.llregression with-mtriple=xtensa -mcpu=esp32s3 -verify-machineinstrs. It passed, covering all three vector shapes, vector memory operations, constants, and Q-register spill pressure.Checklist
Before submitting a Pull Request, please ensure the following: