Age | Commit message (Collapse) | Author | Files | Lines |
|
Fixes #138902
Defines the `Buffer<>` type in the clang frontend. Lowering from
IR->Target Machine is already handled by other code
|
|
(#138976)
Adds constructor for resources with implicit binding and applies it to
all resources without binding at the global scope.
Adds Clang builtin function
`__builtin_hlsl_resource_handlefromimplicitbinding` that gets translated
to `llvm.dx|spv.resource.handlefromimplicitbinding` intrinsic calls.
Specific bindings are assigned in DXILResourceImplicitBinding pass.
Design proposals:
https://github.com/llvm/wg-hlsl/blob/main/proposals/0024-implicit-resource-binding.md
https://github.com/llvm/wg-hlsl/blob/main/proposals/0025-resource-constructors.md
One change from the proposals is that the `orderId` parameter is added
onto the constructor. Originally it was supposed to be generated in
codegen when the `llvm.dx|spv.resource.handlefromimplicitbinding` call
is emitted, but that is not possible because the call is inside a
constructor, and the constructor body is generated once per resource
type and not resource instance. So the only way to inject instance-based
data like `orderId` into the
`llvm.dx|spv.resource.handlefromimplicitbinding` call is that it must
come in via the constructor argument.
Closes #136784
|
|
- Adds resource constructor that takes explicit binding for all resource
classes.
- Updates implementation of default resource constructor to initialize
resource handle to `poison`.
- Removes initialization of resource classes from Codegen.
- Initialization of `cbuffer` still needs to happen in `CGHLSLRuntime`
because it does not have a corresponding resource class type.
- Adds `ImplicitCastExpr` for builtin function calls. Sema adds these
automatically when a method of a template class is instantiated, but
some resource classes like `ByteAddressBuffer` are not templates so they
need to have this added explicitly.
Design proposal: llvm/wg-hlsl#197
Closes #134154
|
|
Moving builder classes into separate files
`HLSLBuiltinTypeDeclBuilder.cpp`/`.h`, changing a some
`HLSLExternalSemaSource` methods to private and removing unused methods.
This is a prep work before we start adding more builtin types and
methods, like textures, resource constructors or matrices. For example
constructors could make use of the `BuiltinTypeMethodBuilder`, but this
helper class was defined in `HLSLExternalSemaSource.cpp` after the
method that creates a constructor. Rather than reshuffling the code one
big source file I am moving the builders into a separate cpp & header
file and placing the helper classes declarations up top.
Currently the new header only exposes `BuiltinTypeDeclBuilder` to
`HLSLExternalSemaSource`. In the future but we might decide to expose
more helper classes as needed.
|
|
Fixes #104862
|
|
Adds `T Load(int)` method on `StructuredBuffer`, `RWStructuredBuffer`
and `RasterizerOrderedStructuredBuffer`.
Uses the existing `addLoadMethods` in HLSLExternalSemalSource so most of
this change is just tests.
Fixes #112977
|
|
This PR adds concept validation to structured buffers, in the same way
that it was done for typed buffers (like RWBuffer) in
https://github.com/llvm/llvm-project/pull/116413.
This PR should also be responsible for introducing rejection of 0 size
elements for structured buffers.
Fixes https://github.com/llvm/llvm-project/issues/117406
|
|
Class BuiltinTypeMethodBuilder has a user-defined destructor so likely
compiler generated special functions may behave incorrectly. Delete
explicitly copy constructor and copy assignment operator to avoid
potential errors.
|
|
This method is the same as `operator[]`, except that it returns a value
instead of a reference.
|
|
Cleaning up some comments that @bogner pointed out were unpolished.
|
|
`Append`/`ConsumeStructuredBuffer` (#118536)
The methods are using existing clang builtins
`__builtin_hlsl_buffer_update_counter` and
`__builtin_hlsl_resource_getpointer` to update the buffer counter and
then load or store the value.
Fixes #112968
|
|
RasterizerOrderedByteAddressBuffer definitions to HLSLExternalSemaSource #113477 (#116699)
This is the first one in a series of PRs adding the requirements for
#58654
This PR adds `ByteAddressBuffer`, `RWByteAddressBuffer ` and
`RasterizerOrderedByteAddressBuffer ` definitions as well as their
handle lowering to `dx.RawBuffer`.
closes #58654
---------
Co-authored-by: Joao Saffran <jderezende@microsoft.com>
|
|
(#117017)
This introduces `__builtin_hlsl_resource_getpointer`, which lowers to
`llvm.dx.resource.getpointer` and is used to implement indexing into
resources.
This will only work through the backend for typed buffers at this point,
but the changes to structured buffers should be correct as far as the
frontend is concerned.
Note: We probably want this to return a reference in the HLSL device
address space, but for now we're just using address space 0. Creating a
device address space and updating this code can be done later as
necessary.
Fixes #95956
|
|
Introduce BuiltinTypeMethodBuilder::PlaceHolder values and use them in
the callBuiltin method in order to specify how we want to forward
arguments and pass the resource handle to builtins.
|
|
(#117608)
Introduces `__builtin_hlsl_buffer_update_counter` clang buildin that is
used to implement the `IncrementCounter` and `DecrementCounter` methods
on `RWStructuredBuffer` and `RasterizerOrderedStructuredBuffer` (see
Note).
The builtin is translated to LLVM intrisic `llvm.dx.bufferUpdateCounter`
or `llvm.spv.bufferUpdateCounter`.
Introduces `BuiltinTypeMethodBuilder` helper in `HLSLExternalSemaSource`
that enables adding methods to builtin types using builder pattern like
this:
```
BuiltinTypeMethodBuilder(Sema, RecordBuilder, "MethodName", ReturnType)
.addParam("param_name", Type, InOutModifier)
.callBuiltin("buildin_name", { BuiltinParams })
.finalizeMethod();
```
Fixes #113513
[First version](llvm/llvm-project#114148) of this PR was reverted
because of build break.
|
|
Detected by misc-use-internal-linkage
|
|
buffers (#114148)" (#117448)
This reverts commit 94bde8cdc39ff7e9c59ee0cd5edda882955242aa.
|
|
(#114148)
Introduces `__builtin_hlsl_buffer_update_counter` clang buildin that is
used to implement the `IncrementCounter` and `DecrementCounter` methods
on `RWStructuredBuffer` and `RasterizerOrderedStructuredBuffer` (see
Note).
The builtin is translated to LLVM intrisic `llvm.dx.bufferUpdateCounter`
or `llvm.spv.bufferUpdateCounter`.
Introduces `BuiltinTypeMethodBuilder` helper in `HLSLExternalSemaSource`
that enables adding methods to builtin types using builder pattern like
this:
```
BuiltinTypeMethodBuilder(Sema, RecordBuilder, "MethodName", ReturnType)
.addParam("param_name", Type, InOutModifier)
.callBuiltin("buildin_name", { BuiltinParams })
.finalizeMethod();
```
Fixes #113513
|
|
This PR is step one on the journey to implement resource element type
validation via C++20 concepts. The PR sets up the infrastructure for
injecting implicit concept decls / concept specialization expressions
into the AST, which will then be evaluated after template arguments are
instantiated. This is not meant to be a complete implementation of the
desired validation for HLSL,
there are a couple of missing elements:
We need the __builtin_hlsl_is_typed_resource_element_compatible builtin
to be implemented.
We need other constraints, like is_intangible
We need to put the first 2 points together, and construct a finalized
constraint expression, which should differ between typed and raw buffers
This is just an initial PR that puts some of the core infrastructure in
place.
This PR is an edit of #112600, so that new tests that were put into main
don't fail
Fixes #75676
|
|
We had an incorrect AST here - We want `const T &`, not `T &const`.
|
|
This is a kind of StructuredBuffer, so it should be "Raw" and not
"Typed".
|
|
This makes it clearer that the handle is an implementation detail by
using a name that's reserved.
|
|
Reverts llvm/llvm-project#112600
|
|
This PR is step one on the journey to implement resource element type
validation via C++20 concepts. The PR sets up the infrastructure for
injecting implicit concept decls / concept specialization expressions
into the AST, which will then be evaluated after template arguments are
instantiated. This is not meant to be a complete implementation of the
desired validation for HLSL,
there are a couple of missing elements:
1. We need the __builtin_hlsl_is_typed_resource_element_compatible
builtin to be implemented.
2. We need other constraints, like is_intangible
3. We need to put the first 2 points together, and construct a finalized
constraint expression, which should differ between typed and raw buffers
This is just an initial PR that puts some of the core infrastructure in
place.
|
|
HLSLExternalSemaSource (#113643)
Adds `AppendStructuredBuffer` and `ConsumeStructuredBuffer` definition
to HLSLExternalSemaSource. Adds separate tests for the AST shape and
element types, and adds constructor/handle.fromBinding test case to
shared test file for structured buffers.
These buffers do not have any subscript operators. Append and Consume
methods will be added later in llvm/llvm-project#112968.
Fixes #112777
|
|
HLSLExternalSemaSource (#113648)
Adds `RasterizerOrderedStructuredBuffer` definition to
HLSLExternalSemaSource. Adds separate tests for the AST shape and
element types. Adds constructor/handle.fromBinding and subscript test
cases to shared test file for structured buffers. Additional methods
will be added later.
Fixes #112776
|
|
(#113649)
|
|
Add tests for RWStructuredBuffer class definition. Use shared test files
for all structured buffers' constructor and subscript tests. Keep AST
and element-type tests separate for each buffer type because they longer
and failures would be harder to match.
Fixes #112775
|
|
Change `StructuredBuffer` resource class to SRV (read-only) to match DXC.
Part of llvm/llvm-project#112775
|
|
convert HLSL types to DirectX target types (#110327)
Translates `RWBuffer` and `StructuredBuffer` resources buffer types to
DirectX target types `dx.TypedBuffer` and `dx.RawBuffer`.
Includes a change of `HLSLAttributesResourceType` from 'sugar' type to
full canonical type. This is required for codegen and other clang
infrastructure to work property on HLSL resource types.
Fixes #95952 (part 2/2)
|
|
`__hlsl_resource_t` builtin type (#110079)
Replace `element_type*` handles in HLSLExternalSemaSource with
`__hlsl_resource_t` builtin type.
The handle used to be defined as `element_type*` which was used by the
provisional subscript operator implementation. Now that the handle is
`__hlsl_resource_t` the subscript placeholder implementation was updated
to add `element_type* e;` field to the resource struct. and return a
reference to that. This field is just a temporary workaround until the
indexing is implemented properly in llvm/llvm-project#95956, at which
point the field will be removed. This seemed like a better solution than
disabling many of the existing tests that already use the `[]` operator.
One test has to be disabled nevertheless because an error based on
interactions of const and template instantiation (potential bug that can
be investigated once indexing is implemented the right way).
Fixes #84824
|
|
The `__builtin_hlsl_create_handle` called from the constructor of
resource buffer class was supposed to initialize the resource handle
based on resource type and registry binding information. It is not
possible to do though that because the registry binding information is
not accessible from the constructor during codegen.
Instead, the handle should be initialized to an empty or null handle
with something like `__builtin_hlsl_create_null_handle`. This PR is
removing `__builtin_hlsl_create_handle` first and the
`__builtin_hlsl_create_null_handle` will be added to the constructor
once the handle type changes to `__hlsl_resource_t` and
HLSLAttributeResourceType is updated to be a canonical type, which will
allow the initialization assignment.
The actual handle initialization based on the registry binding will be
implemented part 2/2 of llvm/llvm-project#105076 once the dependent
tasks are completed.
Part 1/2 of llvm/llvm-project#105076.
|
|
This PR introduces new HLSL resource type attribute
`[[hlsl::raw_buffer]]`. Presence of this attribute on a resource handle
means that the resource does not require typed element access. The
attribute will be used on resource handles that represent buffers like
`StructuredBuffer` or `ByteAddressBuffer` and in DXIL it will be
translated to target extension type `dx.RawBuffer`.
Fixes #107907
|
|
Introducing a new HLSL resource type attribute `[[contained_type(T)]]`
which describes the "contained type" of a buffer or resource type.
Specifically, the attribute will be used on the resource handle in
templated buffer types like so:
template <typename T> struct RWBuffer {
__hlsl_resource_t [[hlsl::contained_type(T)]] [[hlsl::resource_class(UAV)]] h;
};
Fixes #104855
|
|
This PR adds `StructuredBuffer` to `HLSLExternalSemaSource.cpp`, by
copying the logic from RWBuffer but just replacing the name with
StructuredBuffer. The change now allows StructuredBuffers to be defined
in HLSL, though they function the same as RWBuffers.
Further work to apply the appropriate attributes that distinguish
StructuredBuffers from other Buffer types will be deferred.
This improves our position on
https://github.com/llvm/llvm-project/issues/106189
|
|
member (#107160)
Converts existing resource attributes `[[hlsl::resource_class(..)]]` and
`[[is_rov]]` from declaration attributes to type attributes.
During type attribute processing all HLSL resource type attributes are
validated and collected by `SemaHLSL`
(`SemaHLSL::handleResourceTypeAttr`). At the end of the declaration they
are be combined into a single `HLSLAttributedResourceType` instance
(`SemaHLSL::ProcessResourceTypeAttributes`) that wraps the original type
and stores all of the necessary information about the resource.
`SemaHLSL` will also need to short-term-store the `TypeLoc` information
for the newly created type that will be grabbed by `TypeSpecLocFiller`
soon after it is created.
Updates all places that expected resource attributes on declarations
like resource binding diagnostic, builtin types in
HLSLExternalSemaSource, or codegen.
Also includes implementation of
`TreeTransform<Derived>::TransformHLSLAttributedResourceType` that
enables the use of attributed resource types inside templates.
Fixes #104861
Part 2/2
|
|
(#97103)
There are currently no diagnostics being emitted for when a resource is
bound to a register with an incorrect binding type prefix. For example,
a CBuffer type resource should be bound with a a binding type prefix of
'b', but if instead the prefix is 'u', no errors will be emitted. This
PR implements such diagnostics. The focus of this PR is to implement
both the flag setting and diagnostic emisison steps specified in the
relevant spec: https://github.com/microsoft/hlsl-specs/pull/230
The relevant issue is: https://github.com/llvm/llvm-project/issues/57886
This is a continuation / refresh of this PR:
https://github.com/llvm/llvm-project/pull/87578
|
|
new spellable attribute. (#102414)
Much like #98193, this PR takes some more data out of the resource
attribute, specifically the ROV data.
This PR introduces a new attribute called HLSLROVAttr, which contains
data on whether or not the decl the attribute applies to is an ROV.
Tests were added to ensure the attribute is found on the AST.
This attribute may take any boolean condition as an argument. If the
condition is true, then the object the attribute applies to "is" an ROV.
Fixes #https://github.com/llvm/llvm-project/issues/102392
|
|
This PR attaches the resource attributes, `HLSLResourceAttr` and
`HLSLResourceClassAttr`, to the handle contained within such resource
classes like `RWBuffer`. CodeGen will now search for fields within HLSL
resource decls, and emit previous data based on attributes on the handle
member. An AST-dump test was added to verify that the resource attribute
is attached to the handle within the resource record decl.
Fixes #98556
---------
Co-authored-by: Justin Bogner <mail@justinbogner.com>
|
|
This was added in an effort to support resource types before we created
the HLSLResource builtin type, but it isn't needed.
|
|
The ability to spell out and specify the resource class is necessary for
testing various resource binding behaviors. Though it is not intended
for users to use this in customized HLSL source code, the ability to
specify the resource class via an attribute is immensely helpful for
writing thorough tests.
This PR introduces a new attribute, hlsl::resource_attribute, that can
only be applied on structs. This attribute only has 1 required argument,
and must be one of:
```
SRV
UAV
CBuffer
Sampler
```
By applying this attribute to a struct, the struct will have the
`HLSLResourceClassAttr` attribute attached to it in the AST
representation, which provides information on the type of resource class
the struct is meant to be.
The resource class data that was originally contained within the
`HLSLResourceAttr` attribute has been removed in favor of this new
attribute, and so certain ast-dump tests need to be modified so that the
same information can be represented via 2 attributes instead of one.
Fixes #98193
---------
Co-authored-by: Damyan Pepper <damyanp@microsoft.com>
|
|
This is an enabler for https://github.com/llvm/llvm-project/pull/92855
This allows an NTTP default argument to be set as an arbitrary
TemplateArgument, not just an expression.
This allows template parameter packs to have default arguments in the
AST, even though the language proper doesn't support the syntax for it.
This allows NTTP default arguments to be other kinds of arguments, like
packs, integral constants, and such.
|
|
This is an enabler for a future patch.
This allows an type-parameter default argument to be set as an arbitrary
TemplateArgument, not just a type.
This allows template parameter packs to have default arguments in the
AST, even though the language proper doesn't support the syntax for it.
This will be used in a later patch which synthesizes template parameter
lists with arbitrary default arguments taken from template
specializations.
There are a few places we used SubsType, because we only had a type, now
we use SubstTemplateArgument.
SubstTemplateArgument was missing arguments for setting Instantiation
location and entity names.
Adding those is needed so we don't regress in diagnostics.
|
|
non-existent members of the current instantiation prior to instantiation in the absence of dependent base classes (#84050)" (#90152)
Reapplies #84050, addressing a bug which cases a crash when an
expression with the type of the current instantiation is used as the
_postfix-expression_ in a class member access expression (arrow form).
|
|
non-existent members of the current instantiation prior to instantiation in the absence of dependent base classes (#84050)"
This reverts commit a8fd0d029dca7d17eee72d0445223c2fe1ee7758.
|
|
members of the current instantiation prior to instantiation in the absence of dependent base classes (#84050)
Consider the following:
```cpp
template<typename T>
struct A
{
auto f()
{
return this->x;
}
};
```
Although `A` has no dependent base classes and the lookup context for
`x` is the current instantiation, we currently do not diagnose the
absence of a member `x` until `A<T>::f` is instantiated. This patch
moves the point of diagnosis for such expressions to occur at the point
of definition (i.e. prior to instantiation).
|
|
Define HLSL's RasterizerOrderedBuffer resource type through the
external sema source. This doesn't fully work as is, but defining it
allows us to exercise the ROV logic in the DirectX backend from HLSL
rather than having to manually edit metadata, so it's useful for
further testing and development.
Pull Request: https://github.com/llvm/llvm-project/pull/74897
|
|
Pull Request: https://github.com/llvm/llvm-project/pull/74896
|
|
A few changes to HLSLExternalSemaSource and its BuiltinTypeDeclBuilder
to make defining buffer types less verbose. This will make it a lot
easier to see what the differences between the various buffer types
are once we start introducing more of them.
Pull Request: https://github.com/llvm/llvm-project/pull/73967
|
|
RWBuffer doesn't have a default type in dxc's implementation, so it
shouldn't have one in clang either.
Reviewers: llvm-beanz, python3kgae
Reviewed By: python3kgae, llvm-beanz
Pull Request: https://github.com/llvm/llvm-project/pull/71265
|