This is an archive of the discontinued LLVM Phabricator instance.

TableGen: Introduce generated getSubRegisterClass function
ClosedPublic

Authored by arsenm on Aug 1 2022, 3:45 PM.

Details

Reviewers
qcolombet
MatzeB
foad
Group Reviewers
Restricted Project
Summary

Currently there isn't a generic way to get a smaller register class
that can be produced from a subregister of a larger class. Replaces a
manually implemented version for AMDGPU. This will be used to improve
subregister support in the allocator.

Diff Detail

Event Timeline

arsenm created this revision.Aug 1 2022, 3:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2022, 3:45 PM
arsenm requested review of this revision.Aug 1 2022, 3:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2022, 3:45 PM
Herald added a subscriber: wdng. · View Herald Transcript
foad added inline comments.Aug 2 2022, 3:18 AM
llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
276–277

Why add this "if", given that the generated method handles the NoSubregister case?

llvm/utils/TableGen/RegisterInfoEmitter.cpp
1554

I know this is copied from above but it should be <= not <.

1589

This looks like you are handling the NoSubregister case.

arsenm added inline comments.Aug 2 2022, 12:59 PM
llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
276–277

I was thinking it isn't very useful to call if there's a subregister. I blindly copied the 0 case from getSubRegClass

foad added inline comments.Aug 3 2022, 1:41 AM
llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
276–277

I have a slight preference for being able to call getSubRegisterClass unconditionally.

arsenm updated this revision to Diff 450306.Aug 5 2022, 9:00 AM

Address comments and cleanups

foad accepted this revision.Sep 12 2022, 5:57 AM

LGTM, just nits inline.

llvm/include/llvm/CodeGen/TargetRegisterInfo.h
632

"SubRegIdx".

llvm/lib/Target/AMDGPU/SIRegisterInfo.h
281

Jus bikeshedding on the name: would getRegClassForRegOperand make more sense, or just getRegClassForOperand?

This revision is now accepted and ready to land.Sep 12 2022, 5:57 AM
arsenm added inline comments.Sep 12 2022, 5:58 AM
llvm/lib/Target/AMDGPU/SIRegisterInfo.h
281

It's specifically getting the class of the virtual register in the operand, not the underlying register class implied by the instruction

foad added inline comments.Sep 12 2022, 6:04 AM
llvm/lib/Target/AMDGPU/SIRegisterInfo.h
281

OK, then I like the current name :)