15 Commits

Author SHA1 Message Date
Finn Plummer
b3963d30a3
[HLSL][RootSignature] Add parsing for RootFlags (#138055)
- defines the `RootFlags` in-memory enum
- defines `parseRootFlags` to parse the various flag enums into a single
`uint32_t`
- adds corresponding unit tests

- improves the diagnostic message for when we provide a non-zero integer
value to the flags

Resolves https://github.com/llvm/llvm-project/issues/126575
2025-05-09 12:40:14 -07:00
Finn Plummer
9be4d64ba0
[HLSL][RootSignature] Add optional parameters for RootConstants (#138007)
- extends `parseRootConstantParams` and the struct to include the
optional parameters of a RootConstant

- adds corresponding unit tests

Part three of and resolves
https://github.com/llvm/llvm-project/issues/126576
2025-05-09 10:46:37 -07:00
Finn Plummer
5494349a5a
[HLSL][RootSignature] Add mandatory parameters for RootConstants (#138002)
- defines the `parseRootConstantParams` function and adds handling for
the mandatory arguments of `num32BitConstants` and `bReg`

- adds corresponding unit tests

Part two of implementing #126576
2025-05-09 09:31:32 -07:00
Finn Plummer
55517f5f44
[HLSL][RootSignature] Add parsing for empty RootConstants (#137999)
- defines the empty RootConstants in-memory struct
- adds test harness for testing it

- adds missing parameter keywords to the lexer (`RootConstants`,
`num32BitConstants`)

First part of implementing:
https://github.com/llvm/llvm-project/issues/126576
2025-05-08 08:24:47 -07:00
Jan Svoboda
985410f87f
[clang] Hide the TargetOptions pointer from CompilerInvocation (#106271)
This PR hides the reference-counted pointer that holds `TargetOptions`
from the public API of `CompilerInvocation`. This gives
`CompilerInvocation` an exclusive control over the lifetime of this
member, which will eventually be leveraged to implement a copy-on-write
behavior.

There are two clients that currently share ownership of that pointer:

* `TargetInfo` - This was refactored to hold a non-owning reference to
`TargetOptions`. The options object is typically owned by the
`CompilerInvocation` or by the new `CompilerInstance::AuxTargetOpts` for
the auxiliary target. This needed a bit of care in `ASTUnit::Parse()` to
keep the `CompilerInvocation` alive.
* `clangd::PreambleData` - This was refactored to exclusively own the
`TargetOptions` that get moved out of the `CompilerInvocation`.
2025-04-28 07:43:26 -07:00
Finn Plummer
9b74dce4a3
[HLSL][RootSignature] Add parsing of remaining Descriptor Table params (#137038)
- defines the special values for `DESCRIPTOR_RANGE_OFFSET_APPEND` and
`unbounded` for the `offset` and `numDescriptors` parameters
respectively

- adds these parmaters to the `DescriptorClause` struct and the params
struct

- plugs in parsing of `numDescriptors` and `offset` into
`parseDescriptorTableClauseParams`

- defines the `unbounded` enum keyword for the lexer to expose to the
parser

- adds corresponding unit tests

Part 5 of #126569
2025-04-25 14:38:02 -07:00
Finn Plummer
fecf0742b1
[HLSL][RootSignature] Add parsing of DescriptorRangeFlags (#136775)
- Defines `parseDescriptorRangeFlags` to establish a pattern of how
flags will be parsed
- Add corresponding unit tests

Part four of implementing #126569
2025-04-25 13:05:30 -07:00
Finn Plummer
3c3992269c
[HLSL][RootSignature] Add parsing of ShaderVisibility to DescriptorTable (#136751)
- Defines `parseShaderVisiblity` to establish how single enums will be
parsed
- Adds unit testing of the visiblity enum

Part three of implementing #126569
2025-04-24 12:32:54 -07:00
Finn Plummer
b8e420e424
Reland "[HLSL][RootSignature] Implement initial parsing of the descriptor table clause params" (#136740)
This pr relands #133800.

It addresses the compilation error of using a shadowed name `Register`
for both the struct name and the data member holding this type:
`Register Register`. It resolves the issues my renaming the data members
called `Register` to `Reg`.

This issue was not caught as the current pre-merge checks do not include
a build of `llvm;clang` using the gcc/g++ compilers and this is not
erroneous with clang/clang++.

Second part of #126569

---------

Co-authored-by: Finn Plummer <finnplummer@microsoft.com>
2025-04-23 11:51:24 -07:00
Finn Plummer
c134e99a2a
Revert "[HLSL][RootSignature] Implement initial parsing of the descriptor table clause params" (#136252)
Reverts llvm/llvm-project#133800

Reverting to resolve the introduce naming collisions.
2025-04-17 20:58:16 -07:00
Finn Plummer
64de8528db
[HLSL][RootSignature] Implement initial parsing of the descriptor table clause params (#133800)
- Defines `ParseDescriptorTableClauseParams` to establish the pattern of
how we will parse parameters in root signatures. Namely, to use
recursive descent parsing in a way that follows closely to the EBNF
notation definition in the root signature spec.

- Implements parsing of two param types: `UInt32` and `Register` to
demonstrate the parsing implementation and allow for unit testing

- Changes the calling convention to use `std::optional` return values
instead of boolean error returns and parameters by reference

Part two of implementing:
https://github.com/llvm/llvm-project/issues/126569

---------

Co-authored-by: Finn Plummer <finnplummer@microsoft.com>
2025-04-17 20:50:51 -07:00
Jan Svoboda
ea0869ccb9 [clang][parse] Fix build of ParseHLSLRootSignatureTest.cpp
Fallout from PR #133467.
2025-04-04 10:20:44 -07:00
Finn Plummer
676755561d
Reland "[HLSL][RootSignature] Implement parsing of a DescriptorTable with empty clauses" (#133958)
This pr relands https://github.com/llvm/llvm-project/pull/133302.

It resolves two issues:
- Linking error during build,
[here](https://github.com/llvm/llvm-project/pull/133302#issuecomment-2767259848).
There was a missing dependency for `clangLex` for the
`ParseHLSLRootSignatureTest.cpp` unit testing. This library was added to
the dependencies to resolve the error. It wasn't caught previously as
the library was transitively linked in most build environments
- Warning of unused declaration,
[here](https://github.com/llvm/llvm-project/pull/133302#issuecomment-2767091368).
There was a usability line in `LexHLSLRootSignature.h` of the form
`using TokenKind = enum RootSignatureToken::Kind` which causes this
error. The declaration is removed from the header file to be used
locally in the `.cpp` files that use it.
Notably, the original pr would also exposed `clang::hlsl::TokenKind` to
everywhere it was included, which had a name clash with
`tok::TokenKind`. This is another motivation to change to the proposed
resolution.

---------

Co-authored-by: Finn Plummer <finnplummer@microsoft.com>
2025-04-01 14:58:30 -07:00
Finn Plummer
5e2860a8d3
Revert "[HLSL][RootSignature] Implement parsing of a DescriptorTable with empty clauses" (#133790)
Reverts llvm/llvm-project#133302

Reverting to inspect build failures that were introduced from use of the
`clang::Preprocessor` in unit testing, as well as, the warning about an
unused declaration. See linked issue for failures.
2025-03-31 13:38:09 -07:00
Finn Plummer
e4b9486056
[HLSL][RootSignature] Implement parsing of a DescriptorTable with empty clauses (#133302)
- defines the Parser class and an initial set of helper methods to
support consuming tokens. functionality is demonstrated through a simple
empty descriptor table test case
- defines an initial in-memory representation of a DescriptorTable
- implements a test harness that will be used to validate the correct
diagnostics are generated. it will construct a dummy pre-processor with
diagnostics consumer to do so

Implements the first part of
https://github.com/llvm/llvm-project/issues/126569
2025-03-31 10:26:51 -07:00