|
44 | 44 | #include "llvm/ADT/iterator_range.h" |
45 | 45 | #include "llvm/Support/Casting.h" |
46 | 46 | #include "llvm/Support/Compiler.h" |
| 47 | +#include "llvm/Support/DXILABI.h" |
47 | 48 | #include "llvm/Support/ErrorHandling.h" |
48 | 49 | #include "llvm/Support/PointerLikeTypeTraits.h" |
49 | 50 | #include "llvm/Support/TrailingObjects.h" |
@@ -6156,6 +6157,54 @@ class BTFTagAttributedType : public Type, public llvm::FoldingSetNode { |
6156 | 6157 | } |
6157 | 6158 | }; |
6158 | 6159 |
|
| 6160 | +class HLSLAttributedResourceType : public Type, public llvm::FoldingSetNode { |
| 6161 | +public: |
| 6162 | + struct Attributes { |
| 6163 | + // Data gathered from HLSL resource attributes |
| 6164 | + llvm::dxil::ResourceClass ResourceClass; |
| 6165 | + uint8_t IsROV : 1; |
| 6166 | + Attributes(llvm::dxil::ResourceClass ResourceClass, bool IsROV) |
| 6167 | + : ResourceClass(ResourceClass), IsROV(IsROV) {} |
| 6168 | + Attributes() : ResourceClass(llvm::dxil::ResourceClass::UAV), IsROV(0) {} |
| 6169 | + }; |
| 6170 | + |
| 6171 | +private: |
| 6172 | + friend class ASTContext; // ASTContext creates these |
| 6173 | + |
| 6174 | + QualType WrappedType; |
| 6175 | + QualType ContainedType; |
| 6176 | + const Attributes Attrs; |
| 6177 | + |
| 6178 | + HLSLAttributedResourceType(QualType Canon, QualType Wrapped, |
| 6179 | + QualType Contained, const Attributes &Attrs) |
| 6180 | + : Type(HLSLAttributedResource, Canon, Wrapped->getDependence()), |
| 6181 | + WrappedType(Wrapped), ContainedType(Contained), Attrs(Attrs) {} |
| 6182 | + |
| 6183 | +public: |
| 6184 | + QualType getWrappedType() const { return WrappedType; } |
| 6185 | + QualType getContainedType() const { return ContainedType; } |
| 6186 | + const Attributes &getAttrs() const { return Attrs; } |
| 6187 | + |
| 6188 | + bool isSugared() const { return true; } |
| 6189 | + QualType desugar() const { return getWrappedType(); } |
| 6190 | + |
| 6191 | + void Profile(llvm::FoldingSetNodeID &ID) { |
| 6192 | + Profile(ID, WrappedType, ContainedType, Attrs); |
| 6193 | + } |
| 6194 | + |
| 6195 | + static void Profile(llvm::FoldingSetNodeID &ID, QualType Wrapped, |
| 6196 | + QualType Contained, const Attributes &Attrs) { |
| 6197 | + ID.AddPointer(Wrapped.getAsOpaquePtr()); |
| 6198 | + ID.AddPointer(Contained.getAsOpaquePtr()); |
| 6199 | + ID.AddInteger(static_cast<uint32_t>(Attrs.ResourceClass)); |
| 6200 | + ID.AddBoolean(Attrs.IsROV); |
| 6201 | + } |
| 6202 | + |
| 6203 | + static bool classof(const Type *T) { |
| 6204 | + return T->getTypeClass() == HLSLAttributedResource; |
| 6205 | + } |
| 6206 | +}; |
| 6207 | + |
6159 | 6208 | class TemplateTypeParmType : public Type, public llvm::FoldingSetNode { |
6160 | 6209 | friend class ASTContext; // ASTContext creates these |
6161 | 6210 |
|
@@ -8579,6 +8628,8 @@ template <typename T> const T *Type::getAsAdjusted() const { |
8579 | 8628 | Ty = A->getModifiedType().getTypePtr(); |
8580 | 8629 | else if (const auto *A = dyn_cast<BTFTagAttributedType>(Ty)) |
8581 | 8630 | Ty = A->getWrappedType().getTypePtr(); |
| 8631 | + else if (const auto *A = dyn_cast<HLSLAttributedResourceType>(Ty)) |
| 8632 | + Ty = A->getWrappedType().getTypePtr(); |
8582 | 8633 | else if (const auto *E = dyn_cast<ElaboratedType>(Ty)) |
8583 | 8634 | Ty = E->desugar().getTypePtr(); |
8584 | 8635 | else if (const auto *P = dyn_cast<ParenType>(Ty)) |
|
0 commit comments