This is a NFC patch to make convertToImmediateForm a light wrapper for converting xform and imm form instructions on PowerPC.
Details
- Reviewers
jsji nemanjai steven.zhang - Group Reviewers
Restricted Project - Commits
- rG9b6e86a1a51f: [PowerPC] refactor convertToImmediateForm - NFC
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| llvm/lib/Target/PowerPC/PPCInstrInfo.cpp | ||
|---|---|---|
| 3300 | Can we use SignExtend64<16>(Imm) in MathExtra.h to simplify? | |
This is something that we wanted to do early before. Thank you for doing this. Some minor comments.
| llvm/lib/Target/PowerPC/PPCInstrInfo.cpp | ||
|---|---|---|
| 2663 | Please update the comments as it is NOT always LI now. | |
| 2663–2664 | I think, it makes more sense to do it as follows so that, we can add more peephole for Imm form if (HasImmForm && transformToImmFormFedByLI) return true; | |
Thanks for your comments @lkail @steven.zhang
Patch updated.
| llvm/lib/Target/PowerPC/PPCInstrInfo.cpp | ||
|---|---|---|
| 2663 | Not very clear about this comment. transformToImmFormFedByLI will check LI opcode inside it like other functions transformToImmFormFedByLI & simplifyToLI | |
| 3300 | good idea | |
| llvm/lib/Target/PowerPC/PPCInstrInfo.cpp | ||
|---|---|---|
| 3425 | APInt Mask = APInt::getBitsSetWithWrap(32, 32 - ME - 1, 32 - MB); // Current APInt::getBitsSetWithWrap sets all bits to 0 if loBit is equal to highBit. // If MB - ME == 1, we expect a full set mask instead of 0. if (MBSrc - MESrc == 1) Mask.setAllBits(); Personally, I think using a raw APInt would be better than above statements? | |
| llvm/lib/Target/PowerPC/PPCInstrInfo.cpp | ||
|---|---|---|
| 3425 | Should be a raw int... not raw APInt | |
| llvm/lib/Target/PowerPC/PPCInstrInfo.cpp | ||
|---|---|---|
| 3425 | If MB - ME == 1, the current implementation is still zero. #include <stdio.h>
int main() {
long long ME=23;
long long MB = ME + 1;
unsigned long long Mask = ((1LLU << (32 - MB)) - 1) & ~((1LLU << (31 - ME)) - 1);
printf("%llx\n", Mask);
return 0;
}clang test.c;./a.out | |
| llvm/lib/Target/PowerPC/PPCInstrInfo.cpp | ||
|---|---|---|
| 3425 | OK, thanks for pointing it out. Then the mask calculated here should be a bug. If MB - ME == 1, we expect full mask instead of zero mask. I suggest we don't fix this in this NFC patch. This patch intends to make the convertToImmediateForm light and mostly move codes from convertToImmediateForm to new created function SimplifyToLI. | |
| llvm/lib/Target/PowerPC/PPCInstrInfo.cpp | ||
|---|---|---|
| 3425 | Agree. | |
Thank you for doing this to make the code more clear. LGTM now.
| llvm/lib/Target/PowerPC/PPCInstrInfo.cpp | ||
|---|---|---|
| 3400 | Maybe, this is another case that can be improved with the APInt utility to make the code more clear. | |
| llvm/lib/Target/PowerPC/PPCInstrInfo.cpp | ||
|---|---|---|
| 3400 | Because InVal can be 32 or 64 bit width, we need to create different width Mask for them. But InVal &= Mask handles 32/64 bit raw integer automatically. | |
Please update the comments as it is NOT always LI now.