aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ASTCommon.cpp
diff options
context:
space:
mode:
authorHelena Kotas <hekotas@microsoft.com>2024-08-05 10:50:34 -0700
committerGitHub <noreply@github.com>2024-08-05 10:50:34 -0700
commit52956b0f705499ae4a268d3629b402ecdc2cbbab (patch)
treeb157059c165865d7c71fe77cba53a2eda62c7eaa /clang/lib/Serialization/ASTCommon.cpp
parentcec341b1423346e783b150bd71cf9f57fe8d7051 (diff)
downloadllvm-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/Serialization/ASTCommon.cpp')
-rw-r--r--clang/lib/Serialization/ASTCommon.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTCommon.cpp b/clang/lib/Serialization/ASTCommon.cpp
index 444a8a3..f30642f 100644
--- a/clang/lib/Serialization/ASTCommon.cpp
+++ b/clang/lib/Serialization/ASTCommon.cpp
@@ -263,6 +263,11 @@ serialization::TypeIdxFromBuiltin(const BuiltinType *BT) {
ID = PREDEF_TYPE_##Id##_ID; \
break;
#include "clang/Basic/AMDGPUTypes.def"
+#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
+ case BuiltinType::Id: \
+ ID = PREDEF_TYPE_##Id##_ID; \
+ break;
+#include "clang/Basic/HLSLIntangibleTypes.def"
case BuiltinType::BuiltinFn:
ID = PREDEF_TYPE_BUILTIN_FN;
break;