This is an archive of the discontinued LLVM Phabricator instance.

Add backend support for new PAL ELF Metadata 3.0
ClosedPublic

Authored by dstuttard on Mar 29 2023, 4:26 AM.

Details

Summary

PAL Metadata 3.0 introduces an explicit structure in metadata for the
programmable registers written out by the compiler backend.
Rather than using opaque registers which can change between different
architectures and requires encoding the bitfield information in the backend,
which may change between versions.

This is the initial minimal implementation that enables the use of PAL Metadata
3.0.

The change itself should be NFC for non-PAL, although the way RSRC2 register is
handled has been changed slightly.

The test is fairly minimal, but checks that the metadata format looks as
expected and verifies a couple of special cases such as tgid_[xyz]_en handling
and PsInputAddr/Ena which also change to explicit fields.

Diff Detail

Event Timeline

dstuttard created this revision.Mar 29 2023, 4:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 29 2023, 4:26 AM
dstuttard requested review of this revision.Mar 29 2023, 4:26 AM
Herald added a project: Restricted Project. · View Herald Transcript

I don't know metadata handling enough to do a proper review, but I found some inline nits.

llvm/lib/Target/AMDGPU/SIProgramInfo.h
39

Fields -> fields?

llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
916

Maybe add assert(idx < 2);?
Or even use an enum, but that may be overkill :)

llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
147

Why not return a msgpack::DocNode* which may be nullptr?

dstuttard updated this revision to Diff 509343.Mar 29 2023, 6:42 AM
dstuttard marked 2 inline comments as done.

Address review comments

clang-format also seemed to make a log of changes - so must have done something
wrong last time.

llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
916

Thanks - good idea.

llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
147

You are right - I'd got too fixated on making the function work like all the others, but the simplest approach is to go with a pointer.

dstuttard edited reviewers, added: arsenm, foad; removed: jdoerfert.Mar 29 2023, 7:46 AM

Matt - the changes here only really affect PAL, but the changes to rsrc2 handling are universal, so I'd appreciate your review.

dstuttard marked an inline comment as done.Mar 29 2023, 7:47 AM
arsenm added inline comments.Mar 31 2023, 2:03 PM
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
582–603

This is a bunch of pure formatting changes that can be pre-committed?

1063–1069

Don't understand the assert or the comment. We infer these off, but are you suggesting something else is ignoring that?

1098

static const StringLiteral table?

dstuttard updated this revision to Diff 511364.Apr 6 2023, 4:21 AM
dstuttard marked an inline comment as done.

Address reviewer comments:

Update some formatting changes.
Clarify a comment.
Change to using static StringLiteral const table.

llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
582–603

It's not just a formatting change - but point taken. I'll upload something that makes this more obvious (formatting reverts to previous style).

1063–1069

For PAL graphics front-ends, the values in the metadata should reflect the information in CurrentProgramInfo - the front end is expected to pass amdgpu-no-workgroup-id-x etc in this situation. Just asserting that this is the case here.
I'll update the comment to make it clearer.

arsenm accepted this revision.Apr 7 2023, 5:08 PM
arsenm added inline comments.
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
1063–1069

Doesn't seem like an appropriate situation for an assert

This revision is now accepted and ready to land.Apr 7 2023, 5:08 PM
This revision was landed with ongoing or failed builds.Apr 14 2023, 1:59 AM
This revision was automatically updated to reflect the committed changes.