This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Allow isAllocatable inheritence from any superclass
ClosedPublic

Authored by critson on Jul 14 2021, 12:58 AM.

Details

Summary

When setting Allocatable on a generated register class check all
superclasses and set Allocatable true if any superclass is
allocatable.

Without this change generated register classes based on an
allocatable class may end up unallocatable due to the topological
inheritance order.

This change primarily effects AMDGPU backend; however, there are
a few changes in MIPs GlobalISel register constraints as a result.

Diff Detail

Event Timeline

critson created this revision.Jul 14 2021, 12:58 AM
critson requested review of this revision.Jul 14 2021, 12:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2021, 12:58 AM

I think it's ok, but it makes me wonder about the other properties. If this one can vary depending on the topological ordering, can VTs or CopyCost (for example) change too? Logically, VTs should be the intersection of VTs over all super classes, other properties may need different treatment.

llvm/utils/TableGen/CodeGenRegisters.cpp
836–839

You could just use any_of for the set of super classes.

critson updated this revision to Diff 358797.Jul 14 2021, 6:04 PM
critson marked an inline comment as done.
  • Rework to use any_of

I think it's ok, but it makes me wonder about the other properties. If this one can vary depending on the topological ordering, can VTs or CopyCost (for example) change too? Logically, VTs should be the intersection of VTs over all super classes, other properties may need different treatment.

I agree there may be other opportunities to improve the multi-inheritance.

For our usage we have an unallocatable superclass with a mix of allocatable and unallocatable subclasses.
All relevant classes have the same VTs, CopyCost, AllocationPriority, etc.
So at present it is the only the Allocatable flag that has been a problem.

VTs does seem to fit as an intersection.
AllocationPriority, CopyCost could be perhaps be maxima, although this could be restrictive.
No idea about AltOrderSelect.
That said, I do not want to increase the scope of this patch beyond Allocatable.

kparzysz accepted this revision.Jul 15 2021, 6:14 AM
This revision is now accepted and ready to land.Jul 15 2021, 6:14 AM
This revision was landed with ongoing or failed builds.Jul 15 2021, 9:03 PM
This revision was automatically updated to reflect the committed changes.