15 Commits

Author SHA1 Message Date
Justin Bogner
58eec851cb
[DirectX] Move resource logic into PrettyPrinter and TranslateMetadata. NFC
Move the module level logic for resources into the pretty printer and translate
metadata passes rather than embedding them in the DXILResource helper. This
will make it easier to migrate towards the target extension type based approach
to resources.

Pull Request: https://github.com/llvm/llvm-project/pull/104446
2024-08-26 16:44:41 -07:00
Justin Bogner
ad7131864f
[DirectX] Move DXIL ResourceKind and ElementType to DXILABI.h. NFC
Pull Request: https://github.com/llvm/llvm-project/pull/78225
2024-01-29 09:51:00 -08:00
Justin Bogner
4f54d71501
[HLSL][DirectX] Move handling of resource element types into the frontend
Rather than shepherding a type name all the way to the backend as a
string and attempting to parse it, get the element type out of the AST
and store that in the resource annotation metadata directly.

Pull Request: https://github.com/llvm/llvm-project/pull/75674
2023-12-18 11:43:52 -07:00
Kazu Hirata
395f9ce30e Use StringRef::{starts,ends}_with (NFC)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
2023-12-16 10:14:44 -08:00
Justin Bogner
7a13e410fd
[DirectX] Move ROV info into HLSL metadata. NFC
Pull Request: https://github.com/llvm/llvm-project/pull/74896
2023-12-09 10:42:45 -08:00
Justin Bogner
18f0da26b2 [HLSL][DirectX] Avoid some unnecessary casting. NFC 2023-12-08 15:38:09 -08:00
Justin Bogner
1abc931d46
[DirectX] Remove redundant resource kind handling. NFC (#70691)
The frontend passes this along since https://reviews.llvm.org/D135335
2023-10-30 13:35:25 -07:00
Justin Bogner
7f9ba1994a [DirectX] Fix two "not all control paths return a value" warnings
These switch statements are fully covered. Add an llvm_unreachable so
that compilers that don't recognize that don't warn.

Differential Revision: https://reviews.llvm.org/D154882
2023-07-10 15:34:15 -07:00
Xiang Li
944f4b2805 [DirectX backend] add support ConstantBuffer to DXILResource.h
class ConstantBuffer is added to save information for cbuffer.
Also add CBufferDataLayout to calculate the size for cbuffer.

Now always use legacy cbuffer layout.
https://reviews.llvm.org/D134998 will add control to disable legacy cbuffer layout.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D136031
2023-01-12 13:42:11 -05:00
Xiang Li
b861507912 [DIrectX backend] emit metadata for entry.
New named metadata "dx.entryPoints" is added to save all entries.

Each entry is in format of
!{ptr to function, name, signature, resource table, extra}

For compute shader, the extra will save num of threads in format of {i32 x, i32 y, i32 z}

For library profile, an empty entry will be added to save the resource table for the library.

Signature and resource table metadata is not generated yet.

Differential Revision: https://reviews.llvm.org/D131807
2022-12-21 14:56:27 -05:00
Xiang Li
13163dd8ab [HLSL] CodeGen hlsl resource binding.
''register(ID, space)'' like register(t3, space1) will be translated into
i32 3, i32 1 as the last 2 operands for resource annotation metadata.

NamedMetadata for CBuffers and SRVs are added as "hlsl.srvs" and "hlsl.cbufs".

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D130951
2022-10-17 14:29:19 -07:00
Chris Bieneman
911d2dc230 [NFC] [HLSL] Move common metadata to LLVMFrontend
This change pulls some code from the DirectX backend into a new
LLVMFrontendHLSL library to share utility data structures between the
HLSL code generation in Clang and the backend in LLVM.

This is a small refactoring as a first start to get code into the
right structure and get the library built and dependencies correct.

Fixes #58000 (https://github.com/llvm/llvm-project/issues/58000)

Reviewed By: python3kgae

Differential Revision: https://reviews.llvm.org/D135110
2022-10-14 13:40:04 -05:00
Xiang Li
1fc78d66ea [DirectX backend] [NFC] Change Resources::write to const.
Change Resources::write to const.
Also fix parameter name.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D135705
2022-10-13 12:38:12 -07:00
Xiang Li
220185552f [DirectX backend] Add analysis to collect DXILResources
Now only DXILTranslateMetadata uses DXILResources, so DXILResourceWrapper is only used by DXILTranslateMetadata.
Once we add lower for createHandle, DXILResourceWrapper will be used in more passes.
Also we can add resource index allocation in DXILResourceWrapper.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D135190
2022-10-06 19:34:29 -07:00
Chris Bieneman
618e5006a5 [DirectX] Generate dx.resources metadata entry
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.

Reviewed By: python3kgae

Differential Revision: https://reviews.llvm.org/D134682
2022-10-04 12:36:39 -05:00