[Lldb-commits] [clang] [lldb] [HLSL] Intangible AST type (PR #97362)
https://github.com/hekota created https://github.com/llvm/llvm-project/pull/97362 llvm/llvm-project#90631 >From a07ea8d187cbba5717b89f5c54138f12993b3ee8 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 6 Jun 2024 11:44:56 -0700 Subject: [PATCH 1/4] wip: Stub out adding an HLSLResource builtin type There are a couple of things that may be wrong here: - Adding the PREDEF_TYPE to ASTBitCodes seems sketchy, but matches prior art. - I skipped name mangling for now - can it come up? - We use an unspellable name in a few places - The type info matches `void *`. Does that make sense? --- clang/include/clang-c/Index.h | 4 +++- clang/include/clang/AST/ASTContext.h| 1 + clang/include/clang/AST/BuiltinTypes.def| 3 +++ clang/include/clang/AST/Type.h | 12 clang/include/clang/Serialization/ASTBitCodes.h | 5 - clang/lib/AST/ASTContext.cpp| 8 clang/lib/AST/ExprConstant.cpp | 1 + clang/lib/AST/ItaniumMangle.cpp | 4 clang/lib/AST/MicrosoftMangle.cpp | 5 + clang/lib/AST/NSAPI.cpp | 1 + clang/lib/AST/Type.cpp | 3 +++ clang/lib/AST/TypeLoc.cpp | 1 + clang/lib/CodeGen/CGDebugInfo.cpp | 5 + clang/lib/CodeGen/CGDebugInfo.h | 1 + clang/lib/CodeGen/CGHLSLRuntime.cpp | 13 + clang/lib/CodeGen/CGHLSLRuntime.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp | 4 clang/lib/CodeGen/ItaniumCXXABI.cpp | 1 + clang/lib/Index/USRGeneration.cpp | 2 ++ clang/lib/Serialization/ASTCommon.cpp | 3 +++ clang/lib/Serialization/ASTReader.cpp | 3 +++ clang/tools/libclang/CIndex.cpp | 1 + clang/tools/libclang/CXType.cpp | 2 ++ .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp| 2 ++ 24 files changed, 85 insertions(+), 2 deletions(-) diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index ce2282937f86c..b47407f571dfe 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -2966,7 +2966,9 @@ enum CXTypeKind { CXType_ExtVector = 176, CXType_Atomic = 177, - CXType_BTFTagAttributed = 178 + CXType_BTFTagAttributed = 178, + + CXType_HLSLResource = 179 }; /** diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index de86cb5e9d7fc..57e4d7c7c6d33 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1130,6 +1130,7 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/OpenCLImageTypes.def" CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy; CanQualType OCLQueueTy, OCLReserveIDTy; + CanQualType HLSLResourceTy; CanQualType IncompleteMatrixIdxTy; CanQualType ArraySectionTy; CanQualType OMPArrayShapingTy, OMPIteratorTy; diff --git a/clang/include/clang/AST/BuiltinTypes.def b/clang/include/clang/AST/BuiltinTypes.def index 444be4311a743..74c6585688a71 100644 --- a/clang/include/clang/AST/BuiltinTypes.def +++ b/clang/include/clang/AST/BuiltinTypes.def @@ -257,6 +257,9 @@ BUILTIN_TYPE(OCLQueue, OCLQueueTy) // OpenCL reserve_id_t. BUILTIN_TYPE(OCLReserveID, OCLReserveIDTy) +// HLSL resource type +BUILTIN_TYPE(HLSLResource, HLSLResourceTy) + // This represents the type of an expression whose type is // totally unknown, e.g. 'T::foo'. It is permitted for this to // appear in situations where the structure of the type is diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 61246479188e9..720ce7715903c 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2626,6 +2626,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { bool isBitIntType() const;// Bit-precise integer type bool isOpenCLSpecificType() const;// Any OpenCL specific type + bool isHLSLResourceType() const;// HLSL resource type + bool isHLSLSpecificType() const; // Any HLSL specific type + + /// Determines if this type, which must satisfy /// isObjCLifetimeType(), is implicitly __unsafe_unretained rather /// than implicitly __strong. @@ -7887,6 +7891,14 @@ inline bool Type::isOpenCLSpecificType() const { isQueueT() || isReserveIDT() || isPipeType() || isOCLExtOpaqueType(); } +inline bool Type::isHLSLResourceType() const { + return isSpecificBuiltinType(BuiltinType::HLSLResource); +} + +inline bool Type::isHLSLSpecificType() const { + return isHLSLResourceType(); +} + inline bool Type::isTemplateTypeParmType() const { return isa(CanonicalType); } diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota updated https://github.com/llvm/llvm-project/pull/97362 >From a07ea8d187cbba5717b89f5c54138f12993b3ee8 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 6 Jun 2024 11:44:56 -0700 Subject: [PATCH 1/5] wip: Stub out adding an HLSLResource builtin type There are a couple of things that may be wrong here: - Adding the PREDEF_TYPE to ASTBitCodes seems sketchy, but matches prior art. - I skipped name mangling for now - can it come up? - We use an unspellable name in a few places - The type info matches `void *`. Does that make sense? --- clang/include/clang-c/Index.h | 4 +++- clang/include/clang/AST/ASTContext.h| 1 + clang/include/clang/AST/BuiltinTypes.def| 3 +++ clang/include/clang/AST/Type.h | 12 clang/include/clang/Serialization/ASTBitCodes.h | 5 - clang/lib/AST/ASTContext.cpp| 8 clang/lib/AST/ExprConstant.cpp | 1 + clang/lib/AST/ItaniumMangle.cpp | 4 clang/lib/AST/MicrosoftMangle.cpp | 5 + clang/lib/AST/NSAPI.cpp | 1 + clang/lib/AST/Type.cpp | 3 +++ clang/lib/AST/TypeLoc.cpp | 1 + clang/lib/CodeGen/CGDebugInfo.cpp | 5 + clang/lib/CodeGen/CGDebugInfo.h | 1 + clang/lib/CodeGen/CGHLSLRuntime.cpp | 13 + clang/lib/CodeGen/CGHLSLRuntime.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp | 4 clang/lib/CodeGen/ItaniumCXXABI.cpp | 1 + clang/lib/Index/USRGeneration.cpp | 2 ++ clang/lib/Serialization/ASTCommon.cpp | 3 +++ clang/lib/Serialization/ASTReader.cpp | 3 +++ clang/tools/libclang/CIndex.cpp | 1 + clang/tools/libclang/CXType.cpp | 2 ++ .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp| 2 ++ 24 files changed, 85 insertions(+), 2 deletions(-) diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index ce2282937f86c..b47407f571dfe 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -2966,7 +2966,9 @@ enum CXTypeKind { CXType_ExtVector = 176, CXType_Atomic = 177, - CXType_BTFTagAttributed = 178 + CXType_BTFTagAttributed = 178, + + CXType_HLSLResource = 179 }; /** diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index de86cb5e9d7fc..57e4d7c7c6d33 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1130,6 +1130,7 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/OpenCLImageTypes.def" CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy; CanQualType OCLQueueTy, OCLReserveIDTy; + CanQualType HLSLResourceTy; CanQualType IncompleteMatrixIdxTy; CanQualType ArraySectionTy; CanQualType OMPArrayShapingTy, OMPIteratorTy; diff --git a/clang/include/clang/AST/BuiltinTypes.def b/clang/include/clang/AST/BuiltinTypes.def index 444be4311a743..74c6585688a71 100644 --- a/clang/include/clang/AST/BuiltinTypes.def +++ b/clang/include/clang/AST/BuiltinTypes.def @@ -257,6 +257,9 @@ BUILTIN_TYPE(OCLQueue, OCLQueueTy) // OpenCL reserve_id_t. BUILTIN_TYPE(OCLReserveID, OCLReserveIDTy) +// HLSL resource type +BUILTIN_TYPE(HLSLResource, HLSLResourceTy) + // This represents the type of an expression whose type is // totally unknown, e.g. 'T::foo'. It is permitted for this to // appear in situations where the structure of the type is diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 61246479188e9..720ce7715903c 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2626,6 +2626,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { bool isBitIntType() const;// Bit-precise integer type bool isOpenCLSpecificType() const;// Any OpenCL specific type + bool isHLSLResourceType() const;// HLSL resource type + bool isHLSLSpecificType() const; // Any HLSL specific type + + /// Determines if this type, which must satisfy /// isObjCLifetimeType(), is implicitly __unsafe_unretained rather /// than implicitly __strong. @@ -7887,6 +7891,14 @@ inline bool Type::isOpenCLSpecificType() const { isQueueT() || isReserveIDT() || isPipeType() || isOCLExtOpaqueType(); } +inline bool Type::isHLSLResourceType() const { + return isSpecificBuiltinType(BuiltinType::HLSLResource); +} + +inline bool Type::isHLSLSpecificType() const { + return isHLSLResourceType(); +} + inline bool Type::isTemplateTypeParmType() const { return isa(CanonicalType); } diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota updated https://github.com/llvm/llvm-project/pull/97362 >From a07ea8d187cbba5717b89f5c54138f12993b3ee8 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 6 Jun 2024 11:44:56 -0700 Subject: [PATCH 1/6] wip: Stub out adding an HLSLResource builtin type There are a couple of things that may be wrong here: - Adding the PREDEF_TYPE to ASTBitCodes seems sketchy, but matches prior art. - I skipped name mangling for now - can it come up? - We use an unspellable name in a few places - The type info matches `void *`. Does that make sense? --- clang/include/clang-c/Index.h | 4 +++- clang/include/clang/AST/ASTContext.h| 1 + clang/include/clang/AST/BuiltinTypes.def| 3 +++ clang/include/clang/AST/Type.h | 12 clang/include/clang/Serialization/ASTBitCodes.h | 5 - clang/lib/AST/ASTContext.cpp| 8 clang/lib/AST/ExprConstant.cpp | 1 + clang/lib/AST/ItaniumMangle.cpp | 4 clang/lib/AST/MicrosoftMangle.cpp | 5 + clang/lib/AST/NSAPI.cpp | 1 + clang/lib/AST/Type.cpp | 3 +++ clang/lib/AST/TypeLoc.cpp | 1 + clang/lib/CodeGen/CGDebugInfo.cpp | 5 + clang/lib/CodeGen/CGDebugInfo.h | 1 + clang/lib/CodeGen/CGHLSLRuntime.cpp | 13 + clang/lib/CodeGen/CGHLSLRuntime.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp | 4 clang/lib/CodeGen/ItaniumCXXABI.cpp | 1 + clang/lib/Index/USRGeneration.cpp | 2 ++ clang/lib/Serialization/ASTCommon.cpp | 3 +++ clang/lib/Serialization/ASTReader.cpp | 3 +++ clang/tools/libclang/CIndex.cpp | 1 + clang/tools/libclang/CXType.cpp | 2 ++ .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp| 2 ++ 24 files changed, 85 insertions(+), 2 deletions(-) diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index ce2282937f86c..b47407f571dfe 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -2966,7 +2966,9 @@ enum CXTypeKind { CXType_ExtVector = 176, CXType_Atomic = 177, - CXType_BTFTagAttributed = 178 + CXType_BTFTagAttributed = 178, + + CXType_HLSLResource = 179 }; /** diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index de86cb5e9d7fc..57e4d7c7c6d33 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1130,6 +1130,7 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/OpenCLImageTypes.def" CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy; CanQualType OCLQueueTy, OCLReserveIDTy; + CanQualType HLSLResourceTy; CanQualType IncompleteMatrixIdxTy; CanQualType ArraySectionTy; CanQualType OMPArrayShapingTy, OMPIteratorTy; diff --git a/clang/include/clang/AST/BuiltinTypes.def b/clang/include/clang/AST/BuiltinTypes.def index 444be4311a743..74c6585688a71 100644 --- a/clang/include/clang/AST/BuiltinTypes.def +++ b/clang/include/clang/AST/BuiltinTypes.def @@ -257,6 +257,9 @@ BUILTIN_TYPE(OCLQueue, OCLQueueTy) // OpenCL reserve_id_t. BUILTIN_TYPE(OCLReserveID, OCLReserveIDTy) +// HLSL resource type +BUILTIN_TYPE(HLSLResource, HLSLResourceTy) + // This represents the type of an expression whose type is // totally unknown, e.g. 'T::foo'. It is permitted for this to // appear in situations where the structure of the type is diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 61246479188e9..720ce7715903c 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2626,6 +2626,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { bool isBitIntType() const;// Bit-precise integer type bool isOpenCLSpecificType() const;// Any OpenCL specific type + bool isHLSLResourceType() const;// HLSL resource type + bool isHLSLSpecificType() const; // Any HLSL specific type + + /// Determines if this type, which must satisfy /// isObjCLifetimeType(), is implicitly __unsafe_unretained rather /// than implicitly __strong. @@ -7887,6 +7891,14 @@ inline bool Type::isOpenCLSpecificType() const { isQueueT() || isReserveIDT() || isPipeType() || isOCLExtOpaqueType(); } +inline bool Type::isHLSLResourceType() const { + return isSpecificBuiltinType(BuiltinType::HLSLResource); +} + +inline bool Type::isHLSLSpecificType() const { + return isHLSLResourceType(); +} + inline bool Type::isTemplateTypeParmType() const { return isa(CanonicalType); } diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota updated https://github.com/llvm/llvm-project/pull/97362 >From a07ea8d187cbba5717b89f5c54138f12993b3ee8 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 6 Jun 2024 11:44:56 -0700 Subject: [PATCH 1/6] wip: Stub out adding an HLSLResource builtin type There are a couple of things that may be wrong here: - Adding the PREDEF_TYPE to ASTBitCodes seems sketchy, but matches prior art. - I skipped name mangling for now - can it come up? - We use an unspellable name in a few places - The type info matches `void *`. Does that make sense? --- clang/include/clang-c/Index.h | 4 +++- clang/include/clang/AST/ASTContext.h| 1 + clang/include/clang/AST/BuiltinTypes.def| 3 +++ clang/include/clang/AST/Type.h | 12 clang/include/clang/Serialization/ASTBitCodes.h | 5 - clang/lib/AST/ASTContext.cpp| 8 clang/lib/AST/ExprConstant.cpp | 1 + clang/lib/AST/ItaniumMangle.cpp | 4 clang/lib/AST/MicrosoftMangle.cpp | 5 + clang/lib/AST/NSAPI.cpp | 1 + clang/lib/AST/Type.cpp | 3 +++ clang/lib/AST/TypeLoc.cpp | 1 + clang/lib/CodeGen/CGDebugInfo.cpp | 5 + clang/lib/CodeGen/CGDebugInfo.h | 1 + clang/lib/CodeGen/CGHLSLRuntime.cpp | 13 + clang/lib/CodeGen/CGHLSLRuntime.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp | 4 clang/lib/CodeGen/ItaniumCXXABI.cpp | 1 + clang/lib/Index/USRGeneration.cpp | 2 ++ clang/lib/Serialization/ASTCommon.cpp | 3 +++ clang/lib/Serialization/ASTReader.cpp | 3 +++ clang/tools/libclang/CIndex.cpp | 1 + clang/tools/libclang/CXType.cpp | 2 ++ .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp| 2 ++ 24 files changed, 85 insertions(+), 2 deletions(-) diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index ce2282937f86c..b47407f571dfe 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -2966,7 +2966,9 @@ enum CXTypeKind { CXType_ExtVector = 176, CXType_Atomic = 177, - CXType_BTFTagAttributed = 178 + CXType_BTFTagAttributed = 178, + + CXType_HLSLResource = 179 }; /** diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index de86cb5e9d7fc..57e4d7c7c6d33 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1130,6 +1130,7 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/OpenCLImageTypes.def" CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy; CanQualType OCLQueueTy, OCLReserveIDTy; + CanQualType HLSLResourceTy; CanQualType IncompleteMatrixIdxTy; CanQualType ArraySectionTy; CanQualType OMPArrayShapingTy, OMPIteratorTy; diff --git a/clang/include/clang/AST/BuiltinTypes.def b/clang/include/clang/AST/BuiltinTypes.def index 444be4311a743..74c6585688a71 100644 --- a/clang/include/clang/AST/BuiltinTypes.def +++ b/clang/include/clang/AST/BuiltinTypes.def @@ -257,6 +257,9 @@ BUILTIN_TYPE(OCLQueue, OCLQueueTy) // OpenCL reserve_id_t. BUILTIN_TYPE(OCLReserveID, OCLReserveIDTy) +// HLSL resource type +BUILTIN_TYPE(HLSLResource, HLSLResourceTy) + // This represents the type of an expression whose type is // totally unknown, e.g. 'T::foo'. It is permitted for this to // appear in situations where the structure of the type is diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 61246479188e9..720ce7715903c 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2626,6 +2626,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { bool isBitIntType() const;// Bit-precise integer type bool isOpenCLSpecificType() const;// Any OpenCL specific type + bool isHLSLResourceType() const;// HLSL resource type + bool isHLSLSpecificType() const; // Any HLSL specific type + + /// Determines if this type, which must satisfy /// isObjCLifetimeType(), is implicitly __unsafe_unretained rather /// than implicitly __strong. @@ -7887,6 +7891,14 @@ inline bool Type::isOpenCLSpecificType() const { isQueueT() || isReserveIDT() || isPipeType() || isOCLExtOpaqueType(); } +inline bool Type::isHLSLResourceType() const { + return isSpecificBuiltinType(BuiltinType::HLSLResource); +} + +inline bool Type::isHLSLSpecificType() const { + return isHLSLResourceType(); +} + inline bool Type::isTemplateTypeParmType() const { return isa(CanonicalType); } diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota updated https://github.com/llvm/llvm-project/pull/97362 >From a07ea8d187cbba5717b89f5c54138f12993b3ee8 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 6 Jun 2024 11:44:56 -0700 Subject: [PATCH 1/6] wip: Stub out adding an HLSLResource builtin type There are a couple of things that may be wrong here: - Adding the PREDEF_TYPE to ASTBitCodes seems sketchy, but matches prior art. - I skipped name mangling for now - can it come up? - We use an unspellable name in a few places - The type info matches `void *`. Does that make sense? --- clang/include/clang-c/Index.h | 4 +++- clang/include/clang/AST/ASTContext.h| 1 + clang/include/clang/AST/BuiltinTypes.def| 3 +++ clang/include/clang/AST/Type.h | 12 clang/include/clang/Serialization/ASTBitCodes.h | 5 - clang/lib/AST/ASTContext.cpp| 8 clang/lib/AST/ExprConstant.cpp | 1 + clang/lib/AST/ItaniumMangle.cpp | 4 clang/lib/AST/MicrosoftMangle.cpp | 5 + clang/lib/AST/NSAPI.cpp | 1 + clang/lib/AST/Type.cpp | 3 +++ clang/lib/AST/TypeLoc.cpp | 1 + clang/lib/CodeGen/CGDebugInfo.cpp | 5 + clang/lib/CodeGen/CGDebugInfo.h | 1 + clang/lib/CodeGen/CGHLSLRuntime.cpp | 13 + clang/lib/CodeGen/CGHLSLRuntime.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp | 4 clang/lib/CodeGen/ItaniumCXXABI.cpp | 1 + clang/lib/Index/USRGeneration.cpp | 2 ++ clang/lib/Serialization/ASTCommon.cpp | 3 +++ clang/lib/Serialization/ASTReader.cpp | 3 +++ clang/tools/libclang/CIndex.cpp | 1 + clang/tools/libclang/CXType.cpp | 2 ++ .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp| 2 ++ 24 files changed, 85 insertions(+), 2 deletions(-) diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index ce2282937f86c..b47407f571dfe 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -2966,7 +2966,9 @@ enum CXTypeKind { CXType_ExtVector = 176, CXType_Atomic = 177, - CXType_BTFTagAttributed = 178 + CXType_BTFTagAttributed = 178, + + CXType_HLSLResource = 179 }; /** diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index de86cb5e9d7fc..57e4d7c7c6d33 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1130,6 +1130,7 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/OpenCLImageTypes.def" CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy; CanQualType OCLQueueTy, OCLReserveIDTy; + CanQualType HLSLResourceTy; CanQualType IncompleteMatrixIdxTy; CanQualType ArraySectionTy; CanQualType OMPArrayShapingTy, OMPIteratorTy; diff --git a/clang/include/clang/AST/BuiltinTypes.def b/clang/include/clang/AST/BuiltinTypes.def index 444be4311a743..74c6585688a71 100644 --- a/clang/include/clang/AST/BuiltinTypes.def +++ b/clang/include/clang/AST/BuiltinTypes.def @@ -257,6 +257,9 @@ BUILTIN_TYPE(OCLQueue, OCLQueueTy) // OpenCL reserve_id_t. BUILTIN_TYPE(OCLReserveID, OCLReserveIDTy) +// HLSL resource type +BUILTIN_TYPE(HLSLResource, HLSLResourceTy) + // This represents the type of an expression whose type is // totally unknown, e.g. 'T::foo'. It is permitted for this to // appear in situations where the structure of the type is diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 61246479188e9..720ce7715903c 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2626,6 +2626,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { bool isBitIntType() const;// Bit-precise integer type bool isOpenCLSpecificType() const;// Any OpenCL specific type + bool isHLSLResourceType() const;// HLSL resource type + bool isHLSLSpecificType() const; // Any HLSL specific type + + /// Determines if this type, which must satisfy /// isObjCLifetimeType(), is implicitly __unsafe_unretained rather /// than implicitly __strong. @@ -7887,6 +7891,14 @@ inline bool Type::isOpenCLSpecificType() const { isQueueT() || isReserveIDT() || isPipeType() || isOCLExtOpaqueType(); } +inline bool Type::isHLSLResourceType() const { + return isSpecificBuiltinType(BuiltinType::HLSLResource); +} + +inline bool Type::isHLSLSpecificType() const { + return isHLSLResourceType(); +} + inline bool Type::isTemplateTypeParmType() const { return isa(CanonicalType); } diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota ready_for_review https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
hekota wrote: @ChuanqiXu9 - any idea why is your new test `Modules/no-external-type-id.cppm` failing on my PR? It is expecting `// CHECK: https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
@@ -757,7 +757,8 @@ void USRGenerator::VisitType(QualType T) { case BuiltinType::OCLReserveID: Out << "@BT@OCLReserveID"; break; case BuiltinType::OCLSampler: - Out << "@BT@OCLSampler"; break; + Out << "@BT@OCLSampler"; + break; hekota wrote: No, this is probably the clang-format side effect. I'll fix it. https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota updated https://github.com/llvm/llvm-project/pull/97362 >From a07ea8d187cbba5717b89f5c54138f12993b3ee8 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 6 Jun 2024 11:44:56 -0700 Subject: [PATCH 1/7] wip: Stub out adding an HLSLResource builtin type There are a couple of things that may be wrong here: - Adding the PREDEF_TYPE to ASTBitCodes seems sketchy, but matches prior art. - I skipped name mangling for now - can it come up? - We use an unspellable name in a few places - The type info matches `void *`. Does that make sense? --- clang/include/clang-c/Index.h | 4 +++- clang/include/clang/AST/ASTContext.h| 1 + clang/include/clang/AST/BuiltinTypes.def| 3 +++ clang/include/clang/AST/Type.h | 12 clang/include/clang/Serialization/ASTBitCodes.h | 5 - clang/lib/AST/ASTContext.cpp| 8 clang/lib/AST/ExprConstant.cpp | 1 + clang/lib/AST/ItaniumMangle.cpp | 4 clang/lib/AST/MicrosoftMangle.cpp | 5 + clang/lib/AST/NSAPI.cpp | 1 + clang/lib/AST/Type.cpp | 3 +++ clang/lib/AST/TypeLoc.cpp | 1 + clang/lib/CodeGen/CGDebugInfo.cpp | 5 + clang/lib/CodeGen/CGDebugInfo.h | 1 + clang/lib/CodeGen/CGHLSLRuntime.cpp | 13 + clang/lib/CodeGen/CGHLSLRuntime.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp | 4 clang/lib/CodeGen/ItaniumCXXABI.cpp | 1 + clang/lib/Index/USRGeneration.cpp | 2 ++ clang/lib/Serialization/ASTCommon.cpp | 3 +++ clang/lib/Serialization/ASTReader.cpp | 3 +++ clang/tools/libclang/CIndex.cpp | 1 + clang/tools/libclang/CXType.cpp | 2 ++ .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp| 2 ++ 24 files changed, 85 insertions(+), 2 deletions(-) diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index ce2282937f86c..b47407f571dfe 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -2966,7 +2966,9 @@ enum CXTypeKind { CXType_ExtVector = 176, CXType_Atomic = 177, - CXType_BTFTagAttributed = 178 + CXType_BTFTagAttributed = 178, + + CXType_HLSLResource = 179 }; /** diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index de86cb5e9d7fc..57e4d7c7c6d33 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1130,6 +1130,7 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/OpenCLImageTypes.def" CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy; CanQualType OCLQueueTy, OCLReserveIDTy; + CanQualType HLSLResourceTy; CanQualType IncompleteMatrixIdxTy; CanQualType ArraySectionTy; CanQualType OMPArrayShapingTy, OMPIteratorTy; diff --git a/clang/include/clang/AST/BuiltinTypes.def b/clang/include/clang/AST/BuiltinTypes.def index 444be4311a743..74c6585688a71 100644 --- a/clang/include/clang/AST/BuiltinTypes.def +++ b/clang/include/clang/AST/BuiltinTypes.def @@ -257,6 +257,9 @@ BUILTIN_TYPE(OCLQueue, OCLQueueTy) // OpenCL reserve_id_t. BUILTIN_TYPE(OCLReserveID, OCLReserveIDTy) +// HLSL resource type +BUILTIN_TYPE(HLSLResource, HLSLResourceTy) + // This represents the type of an expression whose type is // totally unknown, e.g. 'T::foo'. It is permitted for this to // appear in situations where the structure of the type is diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 61246479188e9..720ce7715903c 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2626,6 +2626,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { bool isBitIntType() const;// Bit-precise integer type bool isOpenCLSpecificType() const;// Any OpenCL specific type + bool isHLSLResourceType() const;// HLSL resource type + bool isHLSLSpecificType() const; // Any HLSL specific type + + /// Determines if this type, which must satisfy /// isObjCLifetimeType(), is implicitly __unsafe_unretained rather /// than implicitly __strong. @@ -7887,6 +7891,14 @@ inline bool Type::isOpenCLSpecificType() const { isQueueT() || isReserveIDT() || isPipeType() || isOCLExtOpaqueType(); } +inline bool Type::isHLSLResourceType() const { + return isSpecificBuiltinType(BuiltinType::HLSLResource); +} + +inline bool Type::isHLSLSpecificType() const { + return isHLSLResourceType(); +} + inline bool Type::isTemplateTypeParmType() const { return isa(CanonicalType); } diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
@@ -2241,6 +2247,11 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = ALIGN; \ break; #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" + Width = 0; hekota wrote: The intangible type is currently implemented as size-less type, but that might change as the HLSL implementation evolves. Setting the width to 0 here matches what similar types from other languages have done, for example `__externref_t` in WebAssembly, which is also an opaque type whose value cannot be accessed or manipulated, only passed around. https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
@@ -115,6 +116,18 @@ GlobalVariable *replaceBuffer(CGHLSLRuntime::Buffer &Buf) { } // namespace +llvm::Type *CGHLSLRuntime::convertHLSLSpecificType(const Type *T) { + assert(T->isHLSLSpecificType() && "Not an HLSL specific type!"); + + // Check if the target has a specific translation for this type first. + if (llvm::Type *TargetTy = CGM.getTargetCodeGenInfo().getHLSLType(CGM, T)) +return TargetTy; + + // TODO: What do we actually want to do generically here? OpenCL uses a + // pointer in a particular address space. + llvm_unreachable("Generic handling of HLSL types is not implemented yet"); hekota wrote: I am not sure if we have any HLSL specific type that will not be handled by `getHLSLType`, so this might just become simple `llvm_unreachable` without the TODO: comment. @bogner? https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
hekota wrote: > I see many places where extra cases have been added for the intangible types > but no corresponding tests. Is that ok? How did you know to update these > places? I looked at similar types in other languages, such as the `image*` types in [OpenCL](https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/OpenCLImageTypes.def) or `__externref_t` in [WebAssembly](https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/WebAssemblyReferenceTypes.def). I used the same implementation style and defaults as these types (except `__externref_t` is a typedef and not a language keyword). Some of the cases are tested when the two `builtin_hlsl_resource_t.hlsl` files are parsed and AST dumped, but it is not possible to test all case until we can actually use the type (llvm/llvm-project#84824). > I also don't see anywhere that actually successfully uses > `__builtin_hlsl_resource_t`. Am I missing it, or should I not expect to see > it? You are correct - the type cannot be directly declared in user code, so the tests only check for errors and that the type shows up properly in AST. It is possible to use this type internally in Clang or in implicit headers though, which are two ways how we could define `RWBuffer` and other builtin types that will internally use `__builtin_hlsl_resource_t` handle. That will come alive in (llvm/llvm-project#84824). https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
@@ -8001,6 +8001,12 @@ NamedDecl *Sema::ActOnVariableDeclarator( } } + if (getLangOpts().HLSL) { +if (R->isHLSLSpecificType() && !NewVD->isImplicit()) { + Diag(D.getBeginLoc(), diag::err_hlsl_intangible_type_cannot_be_declared); hekota wrote: Yes, the intention was that these types can be created only in the implicit header `hlsl.h`. If that's not the case, I will remove this. https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
@@ -8001,6 +8001,12 @@ NamedDecl *Sema::ActOnVariableDeclarator( } } + if (getLangOpts().HLSL) { +if (R->isHLSLSpecificType() && !NewVD->isImplicit()) { + Diag(D.getBeginLoc(), diag::err_hlsl_intangible_type_cannot_be_declared); hekota wrote: Got it, I thought `isImplicit()` also means declarations from implicit headers. If we want to use these in `hlsl.h` then I don't think they can be truly sizeless. Sizeless types does not seem to be allowed in struct fields. https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
@@ -1390,7 +1390,8 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target, #include "clang/Basic/HLSLIntangibleTypes.def" } - if (Target.hasAArch64SVETypes()) { + if (Target.hasAArch64SVETypes() || hekota wrote: I don't see this change in this PR diff. This change was done in llvm/llvm-project#99446 and came in via merge from `main`. https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
@@ -23,7 +23,7 @@ export module b; import a; export int b(); -// CHECK: https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
@@ -115,6 +116,18 @@ GlobalVariable *replaceBuffer(CGHLSLRuntime::Buffer &Buf) { } // namespace +llvm::Type *CGHLSLRuntime::convertHLSLSpecificType(const Type *T) { + assert(T->isHLSLSpecificType() && "Not an HLSL specific type!"); + + // Check if the target has a specific translation for this type first. + if (llvm::Type *TargetTy = CGM.getTargetCodeGenInfo().getHLSLType(CGM, T)) +return TargetTy; + + // TODO: What do we actually want to do generically here? OpenCL uses a + // pointer in a particular address space. + llvm_unreachable("Generic handling of HLSL types is not implemented yet"); hekota wrote: I have removed the comment and left the `llvm_unreachable`. We can revisit this in the future. https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
hekota wrote: > > I also don't see anywhere that actually successfully uses > > `__builtin_hlsl_resource_t`. Am I missing it, or should I not expect to see > > it? > > You are correct - the type cannot be directly declared in user code, so the > tests only check for errors and that the type shows up properly in AST. It is > possible to use this type internally in Clang or in implicit headers though, > which are two ways how we could define `RWBuffer` and other builtin types > that will internally use `__builtin_hlsl_resource_t` handle. That will come > alive in (#84824). The PR has been updated to allow instantiation of `__hlsl_resource_t` in struct fields. https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota closed https://github.com/llvm/llvm-project/pull/97362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits