summaryrefslogtreecommitdiff
path: root/llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp
AgeCommit message (Collapse)Author
2025-10-01[HLSL] Update Frontend to support version 1.2 of root signature (#160616)joaosaffran
This patch updates the frontend to support version 1.2 of root signatures, it adds parsing, metadata generation and a few tests. --------- Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-08-18[NFC][HLSL] Remove confusing enum aliases / duplicates (#153909)Damyan Pepper
Remove: * DescriptorType enum - this almost exactly shadowed the ResourceClass enum * ClauseType aliased ResourceClass Although these were introduced to make the HLSL root signature handling code a bit cleaner, they were ultimately causing confusion as they appeared to be unique enums that needed to be converted between each other. Closes #153890
2025-08-15[HLSL] Refactoring DXILABI.h to not depend on scope printer (#153840)joaosaffran
This patch refactors DXILABI to remove the dependency on scope printer. Closes: #153827 --------- Co-authored-by: Joao Saffran <{ID}+{username}@users.noreply.github.com>
2025-08-14[DirectX] Add Range Overlap validation (#152229)joaosaffran
As part of the Root Signature Spec, we need to validate if Root Signatures are not defining overlapping ranges. Closes: https://github.com/llvm/llvm-project/issues/126645 --------- Co-authored-by: joaosaffran <joao.saffran@microsoft.com> Co-authored-by: Joao Saffran <{ID}+{username}@users.noreply.github.com> Co-authored-by: Joao Saffran <jderezende@microsoft.com>
2025-08-07[NFC][HLSL][DirectX] Consolidate `ResourceClassNames` (#152213)Finn Plummer
During the split of the various `Frontend/HLSL` libraries, there was an oversight to duplicate the `ResourceClassNames` definitions. This commit simply consolidates the definitions into `DXContainer.h` as `getResourceClasses`
2025-08-06[NFC][HLSL] Replace uses of `getResourceName`/`printEnum` (#152211)Finn Plummer
Introduce the `enumToStringRef` enum into `ScopedPrinter.h` that replicates `enumToString` behaviour, expect that instead of returning a hex value string, it just returns an empty string. This allows us to return a StringRef and easily check if an invalid enum was provided based on the StringRef size This then uses `enumToStringRef` to remove the redundant `getResourceName` and `printEnum` functions. Resolves: https://github.com/llvm/llvm-project/issues/151200.
2025-07-04[NFC][HLSL][RootSignature] Split up `HLSLRootSignatureUtils` (#146124)Finn Plummer
This pr breaks-up `HLSLRootSignatureUtils` into separate orthogonal and meaningful libraries. This prevents it ending up as a dumping grounds of many different parts. - Creates a library `RootSignatureMetadata` to contain helper functions for interacting the root signatures in their metadata representation - Create a library `RootSignatureValidations` to contain helper functions that will validate various values of root signatures - Move the serialization of root signature elements to `HLSLRootSignature` Resolves: https://github.com/llvm/llvm-project/issues/145946
2025-06-03[NFC][RootSignature] Move RootSignature util functions (#142491)Finn Plummer
`HLSLRootSignature.h` was originally created to hold the struct definitions of an `llvm::hlsl::rootsig::RootElement` and some helper functions for it. However, there many users of the structs that don't require any of the helper methods. This requires us to link the `FrontendHLSL` library, where we otherwise wouldn't need to. For instance: - This [revert](https://github.com/llvm/llvm-project/pull/142005) was required as it requires linking to the unrequired `FrontendHLSL` library - As part of the change required here: https://github.com/llvm/llvm-project/issues/126557. We will want to add an `HLSLRootSignatureVersion` enum. Ideally this could live with the root signature struct defs, but we don't want to link the helper objects into `clang/Basic/TargetOptions.h` This change allows the struct definitions to be kept in a single header file and to then have the `FrontendHLSL` library only be linked when required.
2025-05-30[HLSL][RootSignature] Metadata generation of RootFlags, RootConstants, ↵Finn Plummer
RootDescriptors (#142010) Implements metadata generation of a Root Signature from its in-memory representation. It follows the same style as: https://github.com/llvm/llvm-project/pull/139633. This pr handles RootFlags, RootConstants and RootDescriptors. The metadata follows the format described [here](https://github.com/llvm/wg-hlsl/blob/main/proposals/0002-root-signature-in-clang.md#metadata-schema). - Implement `BuildRoot[Flags|Constants|Descriptors]` into `HLSLRootSignature.h` - Add sample testcases demonstrating functionality Note: there is no validation of metadata nodes as the `llvm::hlsl::rootsig::RootElement` that generates it will have already been validated. First part of https://github.com/llvm/llvm-project/issues/126586.
2025-05-29Revert "[HLSL][RootSignature] Implement serialization of `RootConstants` and ↵Finn Plummer
`RootFlags`" (#142005) The commit caused build failures, [here](https://lab.llvm.org/buildbot/#/builders/10/builds/6308), due to a missing linked llvm library (HLSLFrontend) into `clang/unittests/Parse/CMakeLists.txt`. While it seems like the fix is straightforwardly to just add this library, I will revert now to build and verify locally it correctly fixes it. Reverts llvm/llvm-project#141130
2025-05-29[HLSL][RootSignature] Implement serialization of `RootConstants` and ↵Finn Plummer
`RootFlags` (#141130) - Implements serialization of the currently completely defined `RootElement`s, namely `RootConstants` and `RootFlags` - Adds unit testing for the serialization methods Resolves: https://github.com/llvm/llvm-project/issues/138190 and https://github.com/llvm/llvm-project/issues/138192
2025-05-22[NFC][HLSL][RootSignature] Use `operator<<` overload instead of dump method ↵Finn Plummer
(#141127) - we will need to provide a way to dump `RootFlags` for serialization and by using operator overloads we can maintain a consistent interface This is an NFC to allow for https://github.com/llvm/llvm-project/issues/138192 to be more straightforwardly implemented.
2025-05-15[HLSL][RootSignature] Add metadata generation for descriptor tables (#139633)Finn Plummer
- prereq: Modify `RootSignatureAttr` to hold a reference to the owned declaration - Define and implement `MetadataBuilder` in `HLSLRootSignature` - Integrate and invoke the builder in `CGHLSLRuntime.cpp` to generate the Root Signature for any associated entry functions - Add tests to demonstrate functionality in `RootSignature.hlsl` Resolves https://github.com/llvm/llvm-project/issues/126584 Note: this is essentially just https://github.com/llvm/llvm-project/pull/125131 rebased onto the new approach of constructing a root signature decl, instead of holding the elements in `AdditionalMembers`.
2025-05-12[HLSL][RootSignature] Define and integrate rootsig clang attr and decl (#137690)Finn Plummer
- Defines a new declaration node `HLSLRootSignature` in `DeclNodes.td` that will consist of a `TrailingObjects` of the in-memory construction of the root signature, namely an array of `hlsl::rootsig::RootElement`s - Defines a new clang attr `RootSignature` which simply holds an identifier to a corresponding root signature declaration as above - Integrate the `HLSLRootSignatureParser` to construct the decl node in `ParseMicrosoftAttributes` and then attach the parsed attr with an identifier to the entry point function declaration. - Defines the various required declaration methods - Add testing that the declaration and reference attr are created correctly, and some syntactical error tests. It was previously proposed that we could have the root elements reference be stored directly as an additional member of the attribute and to not have a separate root signature decl. In contrast, by defining them separately as this change proposes, we will allow a unique root signature to have its own declaration in the AST tree. This allows us to only construct a single root signature for all duplicate root signature attributes. Having it located directly as a declaration might also prove advantageous when we consider root signature libraries. Resolves https://github.com/llvm/llvm-project/issues/119011
2025-05-09[HLSL][RootSignature] Implement serialized dump of Descriptor Tables (#138326)Finn Plummer
- defines the `dump` method for in-memory descriptor table data structs in `Frontend/HLSLRootSignature` - creates unit test infrastructure to support unit tests of the dump methods Resolves https://github.com/llvm/llvm-project/issues/138189