This is an archive of the discontinued LLVM Phabricator instance.

[DirectX] Generate `dx.resources` metadata entry
ClosedPublic

Authored by beanz on Sep 26 2022, 3:00 PM.

Details

Summary

This code adds initial support for generating the HLSL resources
metadata entries. It has a lot of FIXMEs laying around because there
is a lot more work to do here, but this lays a solid groundwork and can
accurately handle some trivial cases.

I've filed a swath of issues covering the deficiencies here and left the
issues in comments so that we can easily follow them.

One big change to make sooner rather than later is to move some of this
code into a new libLLVMFrontendHLSL so that we can share it with the
Clang CodeGen layer.

Diff Detail

Event Timeline

beanz created this revision.Sep 26 2022, 3:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 26 2022, 3:00 PM
beanz requested review of this revision.Sep 26 2022, 3:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 26 2022, 3:00 PM
python3kgae added inline comments.Sep 26 2022, 11:59 PM
llvm/lib/Target/DirectX/DXILResource.h
143–145

Maybe another class like

class HLSL_UAVs {
public:

llvm::SmallVector<UAVResource> UAVs;
HLSL_UAVs() {... call collectUAVs }
~HLSL_UAVs() { remove the "hlsl.uavs" metadata}

private:

void collectUAVs();

};

beanz added inline comments.Sep 27 2022, 1:53 PM
llvm/lib/Target/DirectX/DXILResource.h
143–145

Given that the current class only handles UAVs, I'm not sure the benefit of an extra class. That might make sense as a refactoring as we support more resource types, but for now it seems like an unnecessary abstraction.

python3kgae added inline comments.Sep 27 2022, 2:13 PM
llvm/lib/Target/DirectX/DXILResource.cpp
123–130

This could be in ResourceBase.
Refactoring when we got other resource classes too?

beanz updated this revision to Diff 464749.Oct 3 2022, 11:24 AM

Pulling writing base entries out into ResourceBase::write based on feedback from @python3kgae

python3kgae accepted this revision.Oct 3 2022, 11:34 AM

UAVResource::parseSourceType is really ugly.
It would be nice to fix it in the next PR.

Also a slight format issue.

llvm/lib/Target/DirectX/DXILResource.cpp
147
This revision is now accepted and ready to land.Oct 3 2022, 11:34 AM
This revision was automatically updated to reflect the committed changes.