diff options
author | Cassandra Beckley <beckl.ds@gmail.com> | 2025-05-27 08:40:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-27 11:40:54 -0400 |
commit | 5a4571133af78e365e6e7b271688b9ceaa653e67 (patch) | |
tree | 5018fb04b5ca4301262735fb16d7d27a20414799 /clang/lib/AST/ASTStructuralEquivalence.cpp | |
parent | 58f80536d3ee1a9ca3e8aa62da92d33d4bc9cc8c (diff) | |
download | llvm-5a4571133af78e365e6e7b271688b9ceaa653e67.zip llvm-5a4571133af78e365e6e7b271688b9ceaa653e67.tar.gz llvm-5a4571133af78e365e6e7b271688b9ceaa653e67.tar.bz2 |
[HLSL] Implement `SpirvType` and `SpirvOpaqueType` (#134034)
This implements the design proposed by [Representing SpirvType in
Clang's Type System](https://github.com/llvm/wg-hlsl/pull/181). It
creates `HLSLInlineSpirvType` as a new `Type` subclass, and
`__hlsl_spirv_type` as a new builtin type template to create such a
type.
This new type is lowered to the `spirv.Type` target extension type, as
described in [Target Extension Types for Inline SPIR-V and Decorated
Types](https://github.com/llvm/wg-hlsl/blob/main/proposals/0017-inline-spirv-and-decorated-types.md).
Diffstat (limited to 'clang/lib/AST/ASTStructuralEquivalence.cpp')
-rw-r--r-- | clang/lib/AST/ASTStructuralEquivalence.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp b/clang/lib/AST/ASTStructuralEquivalence.cpp index 499854a..47c8812 100644 --- a/clang/lib/AST/ASTStructuralEquivalence.cpp +++ b/clang/lib/AST/ASTStructuralEquivalence.cpp @@ -1157,6 +1157,23 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, return false; break; + case Type::HLSLInlineSpirv: + if (cast<HLSLInlineSpirvType>(T1)->getOpcode() != + cast<HLSLInlineSpirvType>(T2)->getOpcode() || + cast<HLSLInlineSpirvType>(T1)->getSize() != + cast<HLSLInlineSpirvType>(T2)->getSize() || + cast<HLSLInlineSpirvType>(T1)->getAlignment() != + cast<HLSLInlineSpirvType>(T2)->getAlignment()) + return false; + for (size_t I = 0; I < cast<HLSLInlineSpirvType>(T1)->getOperands().size(); + I++) { + if (cast<HLSLInlineSpirvType>(T1)->getOperands()[I] != + cast<HLSLInlineSpirvType>(T2)->getOperands()[I]) { + return false; + } + } + break; + case Type::Paren: if (!IsStructurallyEquivalent(Context, cast<ParenType>(T1)->getInnerType(), cast<ParenType>(T2)->getInnerType())) |