Configure and use the TSFlags in TargetRegisterClass to
have unique flags for VGPR and AGPR register classes.
The vector register class queries like hasVGPRs will
now become more efficient with just a bitwise operation.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/AMDGPU/SIRegisterInfo.td | ||
---|---|---|
314 | Aren't TSFlags initialized to 0 by default? I think you can drop most of the changes to use SIRegisterClass and only keep it for VGPRs and AGPRs. |
llvm/lib/Target/AMDGPU/SIRegisterInfo.td | ||
---|---|---|
314 | Yes, the bit vector is initialized to zero at its declaration statement in Target.td. I thought having SIRegisterClass everywhere would make it simpler for any additional flags set in the future. |
llvm/lib/Target/AMDGPU/SIRegisterInfo.td | ||
---|---|---|
314 | No strong opinion, but I'd prefer a smaller diff. |
llvm/lib/Target/AMDGPU/SIRegisterInfo.td | ||
---|---|---|
853 | This is suspicious. I wonder why SIRegisterInfo::isVGPR() works. Probably because VS classes are unallocatable and it is called only after selection when we do not have unallocatable classes anymore. Anyway, using this bit on a combined classes seems misleading. Maybe it shall be named 'HasVGPRs' instead? |
llvm/lib/Target/AMDGPU/SIRegisterInfo.td | ||
---|---|---|
853 |
Yes, HasVGPRs flag makes more sense for the combined classes. I will update the patch. | |
853 |
Right, it is possible that SIRegisterInfo::isVGPR() can identify it as an exclusive vgpr class. It is true even with the upstream compiler today. Maybe we don't have a test or a use case to catch it. The unallocatable classes do appear in the register-class query during selection. Do you think it is worth having another flag for SGPRs? |
llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp | ||
---|---|---|
2169–2170 | I think we need a comment here it only works with an allocatable class until we need to change it to work with combined classes. | |
llvm/lib/Target/AMDGPU/SIRegisterInfo.td | ||
853 | It might be beneficial to add an SGPR flag, but not necessarily now. I think all of that will need a revisit when a first combined class will become allocatable. For now a rename of flags shall be OK. |
llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp | ||
---|---|---|
2169–2170 | Not here, actually. That is isVGPRClass would be broken if given a VS class. So it seems we will need a flag for SGPRs and check all 3 flags. Not in this patch. |
I think we need a comment here it only works with an allocatable class until we need to change it to work with combined classes.