diff options
author | Helena Kotas <hekotas@microsoft.com> | 2024-08-05 10:50:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-05 10:50:34 -0700 |
commit | 52956b0f705499ae4a268d3629b402ecdc2cbbab (patch) | |
tree | b157059c165865d7c71fe77cba53a2eda62c7eaa /clang/lib/Sema/DeclSpec.cpp | |
parent | cec341b1423346e783b150bd71cf9f57fe8d7051 (diff) | |
download | llvm-52956b0f705499ae4a268d3629b402ecdc2cbbab.zip llvm-52956b0f705499ae4a268d3629b402ecdc2cbbab.tar.gz llvm-52956b0f705499ae4a268d3629b402ecdc2cbbab.tar.bz2 |
[HLSL] Implement intangible AST type (#97362)
HLSL has a set of intangible types which are described in in the
[draft HLSL Specification
(**[Basic.types]**)](https://microsoft.github.io/hlsl-specs/specs/hlsl.pdf):
There are special implementation-defined types such as handle types,
which fall into a category of standard intangible types. Intangible
types are types that have no defined object representation or value
representation, as such the size is unknown at compile time.
A class type T is an intangible class type if it contains an base
classes or members of intangible class type, standard intangible type,
or arrays of such types. Standard intangible types and intangible class
types are collectively called intangible
types([9](https://microsoft.github.io/hlsl-specs/specs/hlsl.html#Intangible)).
This PR implements one standard intangible type `__hlsl_resource_t`
and sets up the infrastructure that will make it easier to add more
in the future, such as samplers or raytracing payload handles. The
HLSL intangible types are declared in
`clang/include/clang/Basic/HLSLIntangibleTypes.def` and this file is
included with related macro definition in most places that require edits
when a new type is added.
The new types are added as keywords and not typedefs to make sure they
cannot be redeclared, and they can only be declared in builtin implicit
headers. The `__hlsl_resource_t` type represents a handle to a memory
resource and it is going to be used in builtin HLSL buffer types like this:
template <typename T>
class RWBuffer {
[[hlsl::contained_type(T)]]
[[hlsl::is_rov(false)]]
[[hlsl::resource_class(uav)]]
__hlsl_resource_t Handle;
};
Part 1/3 of llvm/llvm-project#90631.
---------
Co-authored-by: Justin Bogner <mail@justinbogner.com>
Diffstat (limited to 'clang/lib/Sema/DeclSpec.cpp')
-rw-r--r-- | clang/lib/Sema/DeclSpec.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index 9a4d52d..5272786 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -377,6 +377,8 @@ bool Declarator::isDeclarationOfFunction() const { case TST_typename_pack_indexing: #define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t: #include "clang/Basic/OpenCLImageTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case TST_##Name: +#include "clang/Basic/HLSLIntangibleTypes.def" return false; case TST_decltype_auto: @@ -608,6 +610,10 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T, case DeclSpec::TST_##ImgType##_t: \ return #ImgType "_t"; #include "clang/Basic/OpenCLImageTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case DeclSpec::TST_##Name: \ + return #Name; +#include "clang/Basic/HLSLIntangibleTypes.def" case DeclSpec::TST_error: return "(error)"; } llvm_unreachable("Unknown typespec!"); |