-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[RISCV] Save vector registers in interrupt handler. #143808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -56,14 +56,44 @@ def CSR_XLEN_F32_Interrupt: CalleeSavedRegs<(add CSR_Interrupt, | |||||||||
| def CSR_XLEN_F64_Interrupt: CalleeSavedRegs<(add CSR_Interrupt, | ||||||||||
| (sequence "F%u_D", 0, 31))>; | ||||||||||
|
|
||||||||||
| // Same as CSR_Interrupt, but including all vector registers. | ||||||||||
| def CSR_XLEN_V_Interrupt: CalleeSavedRegs<(add CSR_Interrupt, | ||||||||||
| (sequence "V%u", 0, 31))>; | ||||||||||
|
|
||||||||||
| // Same as CSR_Interrupt, but including all 32-bit FP registers and all vector | ||||||||||
| // registers. | ||||||||||
| def CSR_XLEN_F32_V_Interrupt: CalleeSavedRegs<(add CSR_Interrupt, | ||||||||||
| (sequence "F%u_F", 0, 31), | ||||||||||
| (sequence "V%u", 0, 31))>; | ||||||||||
|
|
||||||||||
| // Same as CSR_Interrupt, but including all 64-bit FP registers and all vector | ||||||||||
| // registers. | ||||||||||
| def CSR_XLEN_F64_V_Interrupt: CalleeSavedRegs<(add CSR_Interrupt, | ||||||||||
| (sequence "F%u_D", 0, 31), | ||||||||||
| (sequence "V%u", 0, 31))>; | ||||||||||
|
|
||||||||||
| // Same as CSR_Interrupt, but excluding X16-X31. | ||||||||||
| def CSR_Interrupt_RVE : CalleeSavedRegs<(sub CSR_Interrupt, | ||||||||||
| (sequence "X%u", 16, 31))>; | ||||||||||
|
|
||||||||||
| // Same as CSR_XLEN_F32_Interrupt, but excluding X16-X31. | ||||||||||
| def CSR_XLEN_F32_Interrupt_RVE: CalleeSavedRegs<(sub CSR_XLEN_F32_Interrupt, | ||||||||||
| (sequence "X%u", 16, 31))>; | ||||||||||
| (sequence "X%u", 16, 31))>; | ||||||||||
|
|
||||||||||
| // Same as CSR_XLEN_F64_Interrupt, but excluding X16-X31. | ||||||||||
| def CSR_XLEN_F64_Interrupt_RVE: CalleeSavedRegs<(sub CSR_XLEN_F64_Interrupt, | ||||||||||
| (sequence "X%u", 16, 31))>; | ||||||||||
| (sequence "X%u", 16, 31))>; | ||||||||||
|
|
||||||||||
| // Same as CSR_XLEN_V_Interrupt, but excluding X16-X31. | ||||||||||
| def CSR_XLEN_V_Interrupt_RVE: CalleeSavedRegs<(add CSR_Interrupt, | ||||||||||
| (sequence "V%u", 0, 31))>; | ||||||||||
|
||||||||||
| def CSR_XLEN_V_Interrupt_RVE: CalleeSavedRegs<(add CSR_Interrupt, | |
| (sequence "V%u", 0, 31))>; | |
| def CSR_XLEN_V_Interrupt_RVE: CalleeSavedRegs<(add CSR_Interrupt_RVE, | |
| (sequence "V%u", 0, 31))>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct. Unfortunately, vectors+RVE crashes so I couldn't test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use LMUL8 registers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried, but it caused us to spill an LMUL=8 register even if only 1 LMUL=1 register was used. Not sure if we should be optimizing for number of instructions or amount of stack space required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have questions about what we do for the callee saved registers for vector calling convention now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @4vtomat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In vector callee saved registers we just put every combination of vector register class we didn't do anything special lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think callee-saved register also have this issue when I change
llvm-project/llvm/test/CodeGen/RISCV/rvv/callee-saved-regs.ll
Lines 89 to 90 in 4f60321
v24, it usesvs8r.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems the register is set if any of it's alias(including sub-registers and super-registers) is used, so in this case if
v24is clobbered, all of super-registers ofv24in callee-saved lists includingv24,v24m2,v24m4andv24m8is set inSavedRegs.https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/TargetFrameLoweringImpl.cpp#L145-L146