Details
- Reviewers
aykevl dylanmckay - Commits
- rGf319c24570f9: [AVR] Reject/Reserve R0~R15 on AVRTiny.
Diff Detail
Event Timeline
llvm/lib/Target/AVR/AVRCallingConv.td | ||
---|---|---|
39 | I don't think this is needed. Reserved registers are not part of the regular calling convention anyway. | |
llvm/lib/Target/AVR/AVRISelLowering.cpp | ||
1059–1062 | I think it would make sense to use a vector here, to make the code safer. Take a look here to see the recommended vector types for use in LLVM: https://llvm.org/docs/ProgrammersManual.html#sequential-containers-std-vector-std-list-etc | |
llvm/lib/Target/AVR/AVRRegisterInfo.cpp | ||
60–62 | I think it would make sense to change these hardcoded R0/R1/R1R0 registers to properties of AVRSubtarget (a bit like getIORegisterOffset for example). This would make the code below a bit more sensible: it could just reserve R0-R15 instead of R2-R17 which looks a bit strange. |
llvm/lib/Target/AVR/AVRRegisterInfo.cpp | ||
---|---|---|
60–62 | Thanks for your suggestion. But I do not think reserve R0-R15 looks good. Since R0&R1 are always reserved on both avr and avrtiny. While R2-R15 are only reserved on avrtiny. It looks strange like if (STI.hasTinyEncoding()) { for (unsigned Reg = AVR::R0; Reg <= AVR::R17; Reg++) Reserved.set(Reg); else { Reserved.set(R0); Reserved.set(R1); } My points are
|
llvm/lib/Target/AVR/AVRRegisterInfo.cpp | ||
---|---|---|
60–62 | One more issue of doing Reserved.set(getTempReg()); Reserved.set(getZeroReg()); is that, we also have to reserve 16-bit registers R0R1/R16R15/R17R16/R18/R17 on avrtiny. It makes sence to define getTempReg() and getZeroRegs(), but not for something like getTinyReservedRegs(). |
llvm/lib/Target/AVR/AVRCallingConv.td | ||
---|---|---|
39 | Unfortunately this is a must. Since R19 and R18 are callee saved registers on avrtiny, according to https://gcc.gnu.org/wiki/avr-gcc#Reduced_Tiny, though they are not so on normal avr. So we should explicitly mark R19/R18 as callee saved for avrtiny, and exclude R17/R16 from interrupt/singal_handler saved list. |
llvm/lib/Target/AVR/AVRCallingConv.td | ||
---|---|---|
39 | Ah, I see. You are correct. |
llvm/lib/Target/AVR/AVRISelLowering.cpp | ||
---|---|---|
1149–1150 | While updating D131867 I found there is a bug in this code: RegList16 has 6 elements while RegIdx below can be up to 7. This results in an array out of bounds error. |
llvm/lib/Target/AVR/AVRISelLowering.cpp | ||
---|---|---|
1149–1150 | Thanks for your information. I have made a patch to fix that. https://reviews.llvm.org/D138125 Beside changes in the clang side, some extra work is need on the backend, and I will do that later this week. |
llvm/lib/Target/AVR/AVRISelLowering.cpp | ||
---|---|---|
1149–1150 | The corresponding fix in the backend is here, https://reviews.llvm.org/D138201 |
I don't think this is needed. Reserved registers are not part of the regular calling convention anyway.