Dynamically build a mapping table from physical register to base
register class for getPhysRegClass.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Ideally this would be a static table, but the changes required to TableGen to understand register classes for this are non-trivial.
I am seeing >0.5% speed up in compile time with this change.
So the cost of computing the mapping appears negligible compared to the benefit.
The register classes are represented, but there is no way to enumerate all the registers in a register class within a standard structure like GenericTable.
RegisterClass MemberList is a dag after all.
This also prevents iterating over MemberList to define some kind of mapping class between a Register and RegisterClass.
The mapping of registers to register classes is one to many, so it is also not a simple case of modifying TableGen to output a new mapping.
As far as I can tell there is no obvious rule that actually defines the base class for a given register (allocation priority and super classing are insufficient).
The best solution I can see is we extend RegisterClass to allow us to mark which classes are "base classes" and what order to enumerate them to produce a mapping table.
This functionality seems very specific to our needs, so I don't know if that is really an appropriate thing to do.
llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp | ||
---|---|---|
1432–1435 | This will sometimes call getPhysRegBaseClass on a virtual register, which I think should be disallowed. |
llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp | ||
---|---|---|
1434 | It's even easier to do the class test on the virtual register |
llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp | ||
---|---|---|
1434 | I am sorry, I don't know what you mean by "easier". Perhaps you are suggesting we replace most of this code with a call to TRI->isSGPRReg()? |
llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp | ||
---|---|---|
1434 | I mean saying any virtual registers are not SGPRs is wrong; if this is actually reachable with virtual registers it should try to handle them. If not it should assert |
llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp | ||
---|---|---|
1434 | If so that should be a separate patch. This one is NFC. |
llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp | ||
---|---|---|
1434 | I'll work on a separate patch, it is definitely called on virtual registers so an assertion would not be appropriate. Change it to TRI->isSGPRReg() causes failures in later passes so I will have to investigate that in detail. |
It's even easier to do the class test on the virtual register